+ Reply to Thread
Results 1 to 5 of 5

Compile error with format date and time

  1. #1
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Compile error with format date and time

    Hi guys

    When I use the format command with date or time as in the following query then it gives me compile error Expected End of statement.
    Please Login or Register  to view this content.
    Can anyone please tell me how can I change the format of date or time in select statement.

    Regards
    Aman

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Compile error with format date and time

    Aman, first I think we would need to know the Database you're using given the SQL will vary accordingly (ie Access, MySQL, SQLSvr, Oracle, even XL itself)... presumably ScanDate & Time are separate fields ?

  3. #3
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Compile error with format date and time

    Hi ya

    Thanks for your reply. Well the database is in Access and the frontend is excel. The scandate and time are two different fields. Scandate and time both has date/time data type. I have set the format property of scandate to short date and Time format property is set to short time.


    I hope now you got the required information.

    Regards
    Aman

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Compile error with format date and time

    OK, try:

    Please Login or Register  to view this content.
    quotation marks (") are seen as marking beginning / end of string in VBA... if you need to use literally then quote again
    (or you can use: string & Chr(34) & "dd/mm/yyyy" & Chr(34) & rest of string)

  5. #5
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Compile error with format date and time

    Thanks a lot for your help. It worked absolutely fine.

    Cheers

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1