Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 date/month format in sql server

Author  Topic 

vj83
Starting Member

1 Post

Posted - 2007-05-18 : 14:14:16
Hi,

I have a table in which named Emp in which i have three columns namely empid, name and date. In that all the field name data types are varchar including date column. now i have to retrieve the employee list in the order of last date ie., current month & date. Suppose i'm having employee with date 01/05/2007 to 18/05/2007 in dd/mm/yyyy format. I have to retrieve the last date employee details ie., 18/05/2007. For that i used "select max(date) from Emp". But it's displaying only datewise ie., suppose if we give 22/04/2007 after 18/05/2007 in the date column in database, it takes 22/04/2007 and displays it. I think it's taking only the date, but i need to take in the order of month also and have to display 18/05/2007 whatever the order we have inserted in the database.Pls help me with this issue.Sorry for my poor english & for such a vast narration.


Regards
Vijay.

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-05-18 : 14:23:19
obviously, since your date values are not really "date"s in the db. Its a string since your data type is varchar. Can you change the data type in the table to datatime?

Dinakar Nethi
SQL Server MVP
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-05-18 : 14:42:09
Or convert them in the query with convert function.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-05-18 : 19:20:57
hereafter use datetime datatype to store dates


KH

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-05-19 : 01:05:57
Why did you use varchar datatype to store dates?
Use proper dateime datatype and let front end do the formaion

Also you need is to convert them to proper dates

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -