>>Hello,
>>
>>I have an INSERT into command where a DateTime column gets a Date without a time. The Date is passed to this method. So, right now, when I look at this column (in SQL Server Management Studio), I see date and all 0 (zeros) for the time. I would like the INSERT to store the current time when this happens.
>>How do I do it in code? Here is an example of the INSERT:
>>
>> INSERT INTO (cInvenUsedView) ( INVEN_PK, INV_CODE, TRAN_DATE ) VALUES ;
>> ( tnInvenPk, cInvCode, tdPostDate )
>>
>>
>>The value in the above variable tdPostDate is a Date. Can I add the Time right in this SQL Insert?
>>
>>TIA
>
>How 'bout something like:
>
> IF VARTYPE(tdPostDate)=="T" THEN
> * tdPostDate is already a DateTime value
> INSERT INTO (cInvenUsedView) ( INVEN_PK, INV_CODE, TRAN_DATE ) VALUES ;
> ( tnInvenPk, cInvCode, tdPostDate )
> ELSE
> IF VARTYPE((tdPostDate)=="D" THEN
> * tdPostDate is a Date value - add current time
> tNow = DATETIME()
> ttPostDate = DATERTIME(YEAR(m.tdPostDate),MONTH(m.tdPostDate),DAY(m.tdPostDate), HOUR(m.tNow),MINUTE(m.tNow),SEC(m.tNow))
> INSERT INTO (cInvenUsedView) ( INVEN_PK, INV_CODE, TRAN_DATE ) VALUES ;
> ( tnInvenPk, cInvCode, ttPostDate )
> ENDIF
> ENDIF
>
Thank you very much!
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham