Link to home
Create AccountLog in
Avatar of Amanda Walshaw
Amanda WalshawFlag for Australia

asked on

converting julian dates to calendar dates on an int

I have written my query this way

      convert (varchar(10), t2.date_applied, 103) as [date applied],

the field is an int..not datetime

what have I done wrong here. thanks

what i think i need to do here is declare so in my query I should have something like
CAST(convert(varchar, date_applied) as datetime)

is this right?

no this is not quite right as I get this error

Msg 242, Level 16, State 3, Line 2
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

Avatar of cyberkiwi
cyberkiwi
Flag of New Zealand image

What should the int look like?  20101228?
convert(char(8),t2.date_Applied,112)

this expression returns yyyymmdd, which is directly assignable to an int
Avatar of Amanda Walshaw

ASKER

     convert(char(8),t2.date_Applied,112) as [Date Applied],

i have used this expression but I am still gettting julian dates 733862  

i am looking for calander date ie 31-03-2010
ASKER CERTIFIED SOLUTION
Avatar of cyberkiwi
cyberkiwi
Flag of New Zealand image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
this worked