dates dates dates

Results 1 to 2 of 2

Thread: dates dates dates

  1. #1
    Join Date
    Dec 1969

    Default dates dates dates

    ARRRRRRRRRRR<BR><BR>sorry about that!<BR><BR>I am fairly new to ASP and SQL but I am getting the hang of things really well I have created 5 apps which I am very proud of. but their is a thorn in my heal that is limiting my programming creativity, update a date!<BR><BR>I know that I can use the (getDate()) to insert the date that the record is created however if I want to update that record with another date& time I fall upon a problem. I can never find a way of formatting or creating a date to update the record. <BR><BR>I am mainly been using dreamweaver MX <BR><BR>So Guys N Girls what do you reckon.<BR><BR>willa :)<BR>

  2. #2
    Join Date
    Dec 1969

    Default Actually, even that is not true

    getDate() doesn&#039;t supply just the date. It supplies the date *AND* time, same as using NOW() in VBScript.<BR><BR>Getting just the date via TSQL code is a pain in the rear.<BR><BR>As for formatting a date from VBS: You shouldn&#039;t need to.<BR><BR>&#060;%<BR>dateFromForm = Request("someFormField")<BR>If IsDate( dateFromForm ) Then<BR> sqlDate = "&#039;" & CDate(dateFromForm) & "&#039;"<BR>Else<BR> sqlDate = "NULL"<BR>End If<BR><BR>SQL = "UPDATE sometable SET someDateTimeField = " & sqlDate & " WHERE ..."<BR><BR>%&#062;<BR><BR>If you want to play it safe, using a date format that works in any language, with most any database, then write a small VBS function to format the date to ISO format (which is yyyy-mm-dd).<BR>Thus:<BR><BR>&#060;%<BR>Function SQLDate( dt )<BR> If IsDate(dt) Then<BR> dt = CDate(dt) &#039; safety<BR> SQLDate = "&#039;" & Year(dt) & "-" & Month(dt) & "-" & Day(dt) & "&#039;"<BR> Else<BR> SQLDate = "NULL"<BR> End If<BR>End Function<BR><BR>dateFromForm = Request("someFormField")<BR><BR>SQL = "UPDATE sometable SET someDateTimeField = " & SQLDate(dateFromForm) & " WHERE ..."<BR><BR>%&#062;<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts