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.
| Author |
Topic |
|
Exir
Posting Yak Master
151 Posts |
Posted - 2009-05-05 : 03:45:24
|
| I have a date field which is saved in varchar type in this format: dd/mm/yyyy how can i separate and them into day,month and year? |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-05-05 : 03:48:57
|
quote: Originally posted by Exir I have a date field which is saved in varchar type in this format: dd/mm/yyyy how can i separate and them into day,month and year?
1 Use proper DATETIME datatype to store dates so that it is easy to do all date related caculations2 Convert it to proper date and use DATEPART functionMadhivananFailing to plan is Planning to fail |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-05-05 : 03:50:25
|
substring('dd/mm/yyyy',1,2) -- daysubstring('dd/mm/yyyy',4,2) -- monthsubstring('dd/mm/yyyy',7,4) -- year No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Exir
Posting Yak Master
151 Posts |
Posted - 2009-05-05 : 04:01:36
|
| I can not save it in datetime type becouse the date is not in english date and datetime type doesnt save the year less than a special value |
 |
|
|
Exir
Posting Yak Master
151 Posts |
Posted - 2009-05-05 : 04:05:39
|
| thank you webfred it worked |
 |
|
|
|
|
|