?
Solved

storing a date with an ASP and MS Access

Posted on 1998-04-28
6
Medium Priority
?
222 Views
Last Modified: 2013-12-25
I am trying to use the now() and/or getdate() functions in an ASP to initialize a text box with today's date. This works fine. I then use a regular HTML submit to pass that date through several ASP's before actually committing it to the database. It looks like it keeps the right format all the way until it writes it to my Access db.

Now I have a field date_out defined in Access as a date/time data type. When I look in how it is stored in db, Access gives it a default time (not even a date even though I have it formatted as short date only). This prevents me from searching on a date and just pulling out that field.

Does anyone have any idea why my date format would be lost in there?

An idea. That the submit of the form loses the date format and converts it to a string. Yet, Access will usually give an error if you try to assign a string to a date type, as it has when I try to explicitly use a string.

Any thoughts on this?

thanks. a.
0
Comment
Question by:avla
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 28

Expert Comment

by:sybe
ID: 1854341

'Use the ASP Date() function
Today = Date()


I use this function to checkmif a string can be converted to a date:

<%
Function CheckDate(str)
      strInput = str

      On Error Resume Next
      strOutput = CDate(strInput)

      If Err <> 0      Then
            CheckDate = nothing
      Else
            CheckDate = strOutput
      End If

End Function
%>

0
 

Author Comment

by:avla
ID: 1854342
Hi,

Try this


format(now(),date())    give 4/30/98
format(now(),format(time(),"HH:MM:SS AM/PM")) gives 12:22:08 P4






0
 
LVL 6

Expert Comment

by:devtha
ID: 1854343

Thanks for your input but that didn't seem to work either. All I got was type errors.

a.
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!

 

Author Comment

by:avla
ID: 1854344
You said that you pass it through several ASP's...  Is there a way that you can test see if it will commit to the Access DB on the date's first creation from that first ASP?  There is a posibility that you are loosing the date format in the transition from one ASP to another.  That SHOULDN'T happen, but I have seen more weird things than that.  It could be that in the transitions, your date is becoming a string...

SHRUG..  dunno..  I'll try to do something like that and let you know what I find...
0
 

Expert Comment

by:miloa
ID: 1854345
Hey,

I have seen this problem many times before...in that ASP, are you sending the Date to the database via a sql command...i.e. as a text string...

If so, you need to have the Date enclosed within pound signs...so basically something liek this...

sqlString = "Insert into ThisTable (MyDate) VALUES (#" & Date() & "#)"

This is How I Do It...

Hope that worked...let me know, because this question deserves more points...
0
 
LVL 1

Accepted Solution

by:
sclaverie earned 150 total points
ID: 1854346

 I thought that it was still holding the date format but I guess not because when I used your suggestion, it actually worked. It turned out to be a rather simple answer.

 Thanks.

avla
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
Suggested Courses

777 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