PC Review


Reply
 
 
=?Utf-8?B?U0lO?=
Guest
Posts: n/a
 
      28th Mar 2007
hi,
when i insert value (type date) into filed (type date) i get wrong data:
example:
strSQL = "insert into invoice (Payment_Date)"
strSQL = strSQL & " values (" & Me.Payment_Date & ")"

even when i use :
CDate(Me.Payment_Date)
or
Me.Payment_Date : date
i get: 00:06:27
thanks.
 
Reply With Quote
 
 
 
 
Rick Brandt
Guest
Posts: n/a
 
      28th Mar 2007
SIN wrote:
> hi,
> when i insert value (type date) into filed (type date) i get wrong
> data: example:
> strSQL = "insert into invoice (Payment_Date)"
> strSQL = strSQL & " values (" & Me.Payment_Date & ")"
>
> even when i use :
> CDate(Me.Payment_Date)
> or
> Me.Payment_Date : date
> i get: 00:06:27
> thanks.


Date literals need to be delimited with #.

strSQL = "insert into invoice (Payment_Date)"
strSQL = strSQL & " values (#" & Me.Payment_Date & "#)"

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      28th Mar 2007
"Rick Brandt" <(E-Mail Removed)> wrote in message
news:3ExOh.3717$(E-Mail Removed)...
> SIN wrote:
>> hi,
>> when i insert value (type date) into filed (type date) i get wrong
>> data: example:
>> strSQL = "insert into invoice (Payment_Date)"
>> strSQL = strSQL & " values (" & Me.Payment_Date & ")"
>>
>> even when i use :
>> CDate(Me.Payment_Date)
>> or
>> Me.Payment_Date : date
>> i get: 00:06:27
>> thanks.

>
> Date literals need to be delimited with #.
>
> strSQL = "insert into invoice (Payment_Date)"
> strSQL = strSQL & " values (#" & Me.Payment_Date & "#)"


In addition, if you're using dd/mm/yyyy as your Short Date format (or
others), you'll need to ensure that the date is formatted in such as way
that Access will recognize it correctly.

strSQL = "insert into invoice (Payment_Date)"
strSQL = strSQL & " values (" & Format(Me.Payment_Date, "\#yyyy\-mm\-dd\#")
& ")"

or

strSQL = "insert into invoice (Payment_Date)"
strSQL = strSQL & " values (" & Format(Me.Payment_Date, "\#mm\/dd\/yyyy\#")
& ")"


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



 
Reply With Quote
 
=?Utf-8?B?U0lO?=
Guest
Posts: n/a
 
      28th Mar 2007
Thanks

"Douglas J. Steele" wrote:

> "Rick Brandt" <(E-Mail Removed)> wrote in message
> news:3ExOh.3717$(E-Mail Removed)...
> > SIN wrote:
> >> hi,
> >> when i insert value (type date) into filed (type date) i get wrong
> >> data: example:
> >> strSQL = "insert into invoice (Payment_Date)"
> >> strSQL = strSQL & " values (" & Me.Payment_Date & ")"
> >>
> >> even when i use :
> >> CDate(Me.Payment_Date)
> >> or
> >> Me.Payment_Date : date
> >> i get: 00:06:27
> >> thanks.

> >
> > Date literals need to be delimited with #.
> >
> > strSQL = "insert into invoice (Payment_Date)"
> > strSQL = strSQL & " values (#" & Me.Payment_Date & "#)"

>
> In addition, if you're using dd/mm/yyyy as your Short Date format (or
> others), you'll need to ensure that the date is formatted in such as way
> that Access will recognize it correctly.
>
> strSQL = "insert into invoice (Payment_Date)"
> strSQL = strSQL & " values (" & Format(Me.Payment_Date, "\#yyyy\-mm\-dd\#")
> & ")"
>
> or
>
> strSQL = "insert into invoice (Payment_Date)"
> strSQL = strSQL & " values (" & Format(Me.Payment_Date, "\#mm\/dd\/yyyy\#")
> & ")"
>
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Default value in date filed on form Douglas J. Steele Microsoft Access Forms 4 22nd Sep 2009 12:21 PM
Query with two Tables with date filed for Date Range Rag742 Microsoft Access Queries 1 9th Oct 2007 02:42 AM
Clearing a Date filed in an Access DB ? =?Utf-8?B?RGF2aWQ=?= Microsoft ADO .NET 2 15th Sep 2004 06:58 PM
How to Validate a Date Filed. RSB Microsoft ASP .NET 6 21st May 2004 10:06 PM
Dataview row filter on date filed vicky Microsoft ADO .NET 6 21st May 2004 09:43 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:19 AM.