Avatar billede doctorpurple Nybegynder
17. april 2002 - 08:23 Der er 11 kommentarer og
1 løsning

dato konvertering

jeg står og skal bruge en kommando der konvertere dette vb dato ( 16-04-02 07:17:37 ) til SQL              ( 2001-08-17 15:06:49.000 ) jeg er rimelig ny til sql så der må gerne være lidt forklaring    på forhånd tak
Avatar billede terry Ekspert
17. april 2002 - 08:25 #1
so it i something in VB you are doing NOT in SQL
format (datefield, "YYYY-MM-DD hh:mm:ss")
Avatar billede doctorpurple Nybegynder
17. april 2002 - 08:33 #2
my date picker will not give me the right date i just get 17-04-02
Avatar billede terry Ekspert
17. april 2002 - 08:53 #3
How you view (see) the date is controlled by the PC's regional settings, in the datetime field it IS NOT stored like that.

So if you use

"INSERT INTO YourTable (DateField) VALUES ('" & Format(DateTimeFieldFromVB, "YYYY-MM-DD hh:mm:ss) & "')"

then it should work. You need to alter (DateField) to the name of the field in the table and DateTimeFieldFromVB to the name of the datetime variable in VB!
Avatar billede doctorpurple Nybegynder
17. april 2002 - 08:56 #4
Im totally lost I can`t  find that proberty named ( datefield )
Avatar billede doctorpurple Nybegynder
17. april 2002 - 08:58 #5
is this SQL or well I started learning sql for 3 days ago
Avatar billede terry Ekspert
17. april 2002 - 09:02 #6
WHAT is it you are trying to do?

Are you trying to convert a date from VB to date which is acceptable in SQL Server?

Are we in VB (application) or are we talking VB Script? there is a difference!

datefield is NOT a property it is supposed to be one of the fields in your database (table)

Yo will need to give me more information as to what you are doing exactly, sho wthe code or something!
Avatar billede terry Ekspert
17. april 2002 - 09:03 #7
Yes it is SQL!
Avatar billede doctorpurple Nybegynder
17. april 2002 - 09:09 #8
i have a vb application with a adodc control i connect to a sql server.
i have 2 datepickers a start date and a end date  the sql string will list the row with the rigt dates we will list in the datagrid the date is in a row named sd_dato and have this format 2001-08-17 15:06:49.000  my date pickker only returns  16-04-02 but i have a dtpicker as time too it returns 07:17:37  hope it is possible to understand...
Avatar billede terry Ekspert
17. april 2002 - 09:27 #9
Yes I can understand but I am not sure that I can explain exactly how to solve your problem!

DIM sSQL as STRING

sSQL = "SELECT * FROM YourTable WHERE TheDateField Between '"
sSQL = sSQL & Format(dtPicker1Date, "YYYY-MM-DD") & " " & Format(dtPicker1Time, "hh:mm:ss") & "' AND "
sSQL = sSQL & Format(dtPicker2Date, "YYYY-MM-DD") & " " & Format(dtPicker2Time, "hh:mm:ss") & "'"


Now you need to update the controls record source NOTE This IS just and example, you need to alter the name of the control (DataControl) to the name in your program


DataControl.RecordSource = sSQL
DateControl.Refresh
Avatar billede doctorpurple Nybegynder
17. april 2002 - 12:24 #10
thank you again you are a good man
Avatar billede terry Ekspert
17. april 2002 - 12:47 #11
:o)
Avatar billede doctorpurple Nybegynder
17. april 2002 - 16:42 #12
http://exp.dk/spm/199480
take a look its a challenge
Avatar billede Ny bruger Nybegynder

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.

Loading billede Opret Preview
Kategori
Computerworld tilbyder specialiserede kurser i database-management

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester