I'm having a problem with a date variable 
Author Message
 I'm having a problem with a date variable

I have a date variable in a program that contains the contents of a date
field from a table.  When I assign the date variable to another date
variable it doesn't work right but when I assign a date literal (ie
#12/1/99#) to the variable it works properly.  The variable that gets
its value from a table has a value such as 12/1/99.  How can I change
this into a literal?  In other words, how would I put the pound signs
around the date?  Is there any way I can do any date concatenation such
as:

datLiteral = # & variable & #

I wish it was as simple as string concatenation.  I'm sorry I don't have
time to explain myself any better.

I would appreciate any help!

Thanks,
Keith



Tue, 08 Jan 2002 03:00:00 GMT  
 I'm having a problem with a date variable
Hi Keith

You could try using the Format("anydatestring" or Date Literal,"dd/mm/yy").

Dim the Variable as a variant instead of a double.

Regards

Sean

Quote:

>I have a date variable in a program that contains the contents of a date
>field from a table.  When I assign the date variable to another date
>variable it doesn't work right but when I assign a date literal (ie
>#12/1/99#) to the variable it works properly.  The variable that gets
>its value from a table has a value such as 12/1/99.  How can I change
>this into a literal?  In other words, how would I put the pound signs
>around the date?  Is there any way I can do any date concatenation such
>as:

>datLiteral = # & variable & #

>I wish it was as simple as string concatenation.  I'm sorry I don't have
>time to explain myself any better.

>I would appreciate any help!

>Thanks,
>Keith



Wed, 09 Jan 2002 03:00:00 GMT  
 I'm having a problem with a date variable


Quote:
>I have a date variable in a program that contains the contents of a date
>field from a table.

  Dim dtMyDate as Date

  Dim rs as Recordset

  Set rs = something.OpenRecorset(something)

  dtMyDate = rs!MyDateField

  ' Is this right so far?

Quote:
>When I assign the date variable to another date
>variable it doesn't work right

  Dim dtMyOtherDate as Date

  dtMyOtherDate = dtMyDate

  ' this should not cause an error. What exactly
  ' "doesn't work right"?

Quote:
>but when I assign a date literal (ie
>#12/1/99#) to the variable it works properly.

  dtMyOtherDate = #12/1/1999#

  ' These also work:

  dtMyOtherDate = DateSerial(1999, 1, 12)
  dtMyOtherDate = CDate("12 Jan 1999")
  dtMyOtherDate = CDate( "#" & "12/01/1999" & "#" )

  ' and so on.

If that doesn't help, can you tell us where your data are coming from
exactly, and what errors you are getting?

Tim F

--



Thu, 10 Jan 2002 03:00:00 GMT  
 I'm having a problem with a date variable
Did you try "#" & 12/1/99 & "#"?

Dates are weird sometimes.  We formated fields to be mm/dd/yyyy to always
show 4 digit years for Y2K issues.  The default is 12/1/1899!  We ended up
setting date variables as variants to set empty fields.

Dean, PharmTech

Quote:

>I have a date variable in a program that contains the contents of a date
>field from a table.  When I assign the date variable to another date
>variable it doesn't work right but when I assign a date literal (ie
>#12/1/99#) to the variable it works properly.  The variable that gets
>its value from a table has a value such as 12/1/99.  How can I change
>this into a literal?  In other words, how would I put the pound signs
>around the date?  Is there any way I can do any date concatenation such
>as:

>datLiteral = # & variable & #

>I wish it was as simple as string concatenation.  I'm sorry I don't have
>time to explain myself any better.

>I would appreciate any help!

>Thanks,
>Keith



Fri, 11 Jan 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. vb5 i am having problems with lost variables

2. Having problems with locating date values

3. Having problems binding a mask control to a date field

4. Having a date problem

5. I'm having a problem using the MSComm control I hope someone can help

6. I'm having problems querying access database

7. ~~ Help, I'm having file input problems...

8. I'm having a big problem

9. Help I'm having a problem with dbgrid32.ocx in unbound mode

10. I 'm having problems

11. Adding a variable number of weeks to today's date

12. Data Env: 'Where [field]=date' problem

 

 
Powered by phpBB® Forum Software