-
May 19th, 2010, 03:06 AM
#1
How can i change date format
hi dears,
I have this join query
string qry = "Select Users.UserName, Attendence.TimeIn, Attendence.TimeOut from Users Inner Join Attendence on Users.UserID = Attendence.UserID";
where TimeIn and TimeOut are date columns and their date format is dd/mm/yy.
Please tell me how can i change my date format in this join query when retrieving these records from database. I want to show this format like that dd-mm-yy. Pleae guide
-
May 19th, 2010, 06:58 AM
#2
Re: How can i change date format
here is a good list for you...
http://anubhavg.wordpress.com/2009/0...l-server-2005/
the closest one for you is..
SELECT convert(varchar, getdate(), 105)
so your query would now be...
Code:
SELECT
Users.UserName
, CONVERT(varchar, Attendence.TimeIn, 105) As 'TimeIn'
, CONVERT(varchar, Attendence.TimeOut, 105) As 'TimeOut'
FROM
Users
INNER JOIN Attendence
ON Users.UserID = Attendence.UserID
This is assuming the fields are DateTime fields in the database. If not, you will need to convert them to DateTime, then convert them back to varchar.
===============================
My Blog
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|