![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: May 2002
Location: mtl, canada
Posts: 160
|
hello all, i'm trying to make a macro which retrieves data from SQL database. I would like it to retrieve the data for the given date (entered by the user in excel). My problem is that I don't know how to convert my date into a string in VBA so that my macro will be able to retrieve the appropriate information. for example i would like to enter the date 2002-05-09 and i want to convert it in VBA to '2002-05-09 00:00:00' (notice the single quotes. i think that's important because the command is ts '...') thank you.
|
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Apr 2002
Location: Greenwood, SC
Posts: 677
|
I've had similar issues...
Use this for the value you pass to the database: "'" & CStr(EnteredDate) & "09 00:00:00'" K P.S. It doesn't show up very well with this board's font, but the first bunch of quotes is (Double)(Single)(Double) and the last bunch is (Single)(Double). [ This Message was edited by: kkknie on 2002-05-16 06:45 ] |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: May 2002
Location: mtl, canada
Posts: 160
|
Thank you for your reply. I tried your suggestion and it didn`t seem to work, perhaps if i gave u the command.
assuming i've entered the date in cell B1 then to make my call i have to say mydate.Date>={ts '2002-05-09 00:00:00'} now i need to know a) what to enter in B1 (format of date) b) what command to use in VBA? thanks again |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|