09. juli 2005 - 16:09Der er
8 kommentarer og 1 løsning
FormatDateTime(Now, vbShortTime)
Hejsa.
Hvordan kan jeg integrere "FormatDateTime(Now, vbShortTime)" i følgende sql sætning:
sql ="INSERT INTO Breve (BrugerID,AfsenderID,Emne,Post,Dato,Hour,Minute,Time) VALUES ("&""&id&","&Session("bruger")&",'"&top&"','"&send&"','"&CDATE(Date())&"','"&Hour(Time())&"','"&Minute(Time())&"')"
Har prøvet nogle forskellige metoder men kan ikke få det til at virke.. Her er en af dem jeg har prøvet:
sql ="INSERT INTO Breve (BrugerID,AfsenderID,Emne,Post,Dato,Hour,Minute,Time) VALUES ("&""&id&","&Session("bruger")&",'"&top&"','"&send&"','"&CDATE(Date())&"','"&Hour(Time())&"','"&Minute(Time())&"','"&FormatDateTime(Now, vbShortTime)&"')"
What i need is to get the time ONLY printed to my database as xx:xx nothing else but i am having difficulties doing it in my sql.. I have allready done the date ages ago.. Have used this until now '"&Minute(Time())&"' and works like a charm. But when the minute is 1 to 9 it only prints 1, and i need it to print 01 thats why this question is here
Sorry to reject your answer terry, but i really cant use it.
Yes i use an access databse and the field "Time" in the table "Breve", is set to Date/Time - ShortTime and thats what i need (xx:xx). But my problem is i cant figure out how to write it in to the sql, cause im pretty sure i need to format the number, with vbShortTime to get the desired result. The sql is set to execute after clicking on a link, (a link where you send a new email), and i need a timestamb with that and offcourse the date, wich i have allready done.
What i use now as you can see on the above is '"&Hour(Time())&"','"&Minute(Time())&"' and that works. I get my desired result xx:xx when i drag the numbers out of the database. But when the minute is 1 as an example it gives me the result 1 and i need the result 01. Can you see what i mean? 14:01 looks better than 14:1 hehe :) Thats why i need the vbShortTime as that will provide me with the desired result.
Sorry for noty getting back, busy with other things. If you used reserved words in Access just enclose it with [] and it works.
As I mentioned, dates (and times) are always stored in the same way in the database and has NO effect on how you show them. To display dates differently you can I think in VBScript use
No, you solved your own problem, and I have enough thanks.
Have a nice day :o)
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.