Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2007-07-20
9
Medium Priority
?
209 Views
Last Modified: 2010-03-19
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.
0
Comment
Question by:bigtwig
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 400 total points
ID: 19530852
Use the CONVERT function in a SELECT statement:

Select CONVERT(pecADactDate, 101) From Table1

Reference:

CAST and CONVERT
http://msdn2.microsoft.com/en-US/library/aa226054(SQL.80).aspx

Bob
0
 
LVL 2

Author Comment

by:bigtwig
ID: 19530894
Use JavaScript for setting pecADActDate?
0
 
LVL 25

Expert Comment

by:kevp75
ID: 19531081
you could also do this on the form field

formatdatetime(theVariable,2)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 96

Expert Comment

by:Bob Learned
ID: 19531174
SQL Server has the GETDATE() function to get the date for Today, so I don't know why you are talking about Javascript.

Bob
0
 
LVL 2

Author Comment

by:bigtwig
ID: 19531261
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.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19531309
SQL Server can handle dates in MM/DD/YYYY format, so you wouldn't need to do anything else.

Bob
0
 
LVL 2

Author Comment

by:bigtwig
ID: 19531340
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 19531374
SELECT CONVERT(varchar(10),getdate(),101)
0
 
LVL 25

Accepted Solution

by:
kevp75 earned 1600 total points
ID: 19531382
as I previously stated:
<td><input TYPE="Text" Name="ADActDate" SIZE="20" MAXLENGTH="20" value="<%=formatdatetime(ADActDate,2)%>"></td>
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question