January 29, 2003 at 8:40 pm
Hello all,
I have a field in my sql 2000 database that is set as the datetime datatype. Upon inserting into the database i insert the date as 1/29/2003. However, i would like to format this datatype to read January 29 2003. I have no idea how to do this. Can anyone give me a suggestion? I would really appreciate it.
Thanks
January 29, 2003 at 9:43 pm
SQL Books Online: Values with the datetime data type are stored internally by Microsoft SQL Server as two 4-byte integers. The first 4 bytes store the number of days before or after the base date, January 1, 1900. The base date is the system reference date. Values for datetime earlier than January 1, 1753, are not permitted. The other 4 bytes store the time of day represented as the number of milliseconds after midnight.
To get it formatted try SELECT CONVERT(VARCHAR(12),COLUMN1,107). See BOL->convert
January 30, 2003 at 10:35 am
Thanks. I ended up writing a little funtion that did this for me. If anyone wants to use this feel free.
// Date Format Function
evdate = rs("press_date")
On Error Resume Next
evdate = cDate(evdate)
if err = 0 then
yearstring = " " & year(evdate)
if year(evdate) = year(date()) then yearstring = ""
thismonth = month(evdate)
outdate = daterange(evdate,evdate2)
end if
February 4, 2003 at 2:47 pm
On Error Resume Next
if Not IsNull(evdate) And IsDate(rs("press_date").value) Then
evdate=monthname(month(evdate)) & " " & day(evdate) & " " & year(evdate)
Else
evdate=""
end if
Syntax may be wrong for vbscript!
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply