none
Undefined function 'GETDATE' in expression (Ms access connection) RRS feed

  • Question

  • Hi ,

    I am using an Ms access database ,

    with this Function I whant to get dates  which happened to day,

    But I always get :"Undefined function 'GETDATE' in expression" exception is occurent "type 'System.Data.OleDb.OleDbException'". 

    Thank you so much.

        Public Function GetDateMirage1() As DataTable
            Dim dt As New DataTable
    
            Dim selectStatement As String =
                    <SQL>
                
                        Select   PID,Cage,Race
    
                    ,DatedePonte
                    ,DatedeCouvaison
                    ,DatedeMirage
                    ,Datedéclosion
                    From Ponte1  WHERE (DatedeMirage >=DATEADD(day, DATEDIFF(day,0,GETDATE()),0) 
                    AND DatedeMirage &#60;DATEADD(day, DATEDIFF(day,0,GETDATE())+1,0))  
    
    
     </SQL>.Value
    
            Using con = New OleDbConnection(cs)
                Using cmd = New OleDbCommand() With
                    {
                        .Connection = con,
                        .CommandText = selectStatement
                    }
                    con.Open()
    
                    dt.Load(cmd.ExecuteReader())
    
                End Using
            End Using
    
            Return dt
    
        End Function


    • Edited by Bajtitou Monday, February 25, 2019 8:24 AM
    Monday, February 25, 2019 8:23 AM

Answers

  • Hello,

    GETDATE() is SQL-Server, if this is working with MS-Access then use DATE()


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Marked as answer by Bajtitou Monday, February 25, 2019 5:36 PM
    Monday, February 25, 2019 10:12 AM
    Moderator

All replies

  • Hi,

    I tried your code,it works well.

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, February 25, 2019 9:24 AM
  • Hi, 

    Not for me !

    Are you using an Ms access DB?

    This Is a screem screenshot.

    Thank you very much.

    Monday, February 25, 2019 9:54 AM
  • Hello,

    GETDATE() is SQL-Server, if this is working with MS-Access then use DATE()


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Marked as answer by Bajtitou Monday, February 25, 2019 5:36 PM
    Monday, February 25, 2019 10:12 AM
    Moderator
  • Hello,

    GETDATE() is SQL-Server, if this is working with MS-Access then use DATE()

    --------------------------------------------------------------------------------------

    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Hi, 

    Thank you so Much .

    Best regards.


    • Edited by Bajtitou Monday, February 25, 2019 5:39 PM
    Monday, February 25, 2019 5:38 PM