Link to home
Start Free TrialLog in
Avatar of bigtwig
bigtwig

asked on

Displaying/Storing Today's Date in ASP/SQL Server

SQL Server and ASP.  pecADActDate is mapped as smalldatetime on SQL.  I have a form and want to set that variable to today.  I'd like it to display the date MM/DD/YY or MM-DD-YYYY (something very USAish) when the form opens but still store it (and allow changes) as smalldatetime.  Thanks.
SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bigtwig
bigtwig

ASKER

Use JavaScript for setting pecADActDate?
you could also do this on the form field

formatdatetime(theVariable,2)
SQL Server has the GETDATE() function to get the date for Today, so I don't know why you are talking about Javascript.

Bob
Avatar of bigtwig

ASKER

OK, I need to back up.
I have a form with a variable, ADActDate, that I want to set to Today's Date when the form loads.  It should display in the form and be editable.  This is the cell that I have:
<td><input TYPE="Text" Name="ADActDate" SIZE="20" MAXLENGTH="20" value="<%=ADActDate%>"></td>

How do I set ADActDate to today when the form loads and display MM/DD/YYYY.

If I do this, am I all set when I do my SQL Update?
      If IsDate(Request.QueryString("ADActDate")) Then
            ADActDate = CDate(Request.QueryString("ADActDate"))
      Else
            ADActDate = Date
      End If

Thanks.
SQL Server can handle dates in MM/DD/YYYY format, so you wouldn't need to do anything else.

Bob
SELECT CONVERT(varchar(10),getdate(),101)
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial