Skip to main content
Inspiring
June 11, 2017
Question

select date

  • June 11, 2017
  • 4 replies
  • 2675 views

<cfset DateSelect=16/07/2017>

<cfset NumJour=#Dayofweek(DateSelect -1)#>

<cfset Dim=#dateadd('D',-NumJour,DateSelect)#>

<CFQUERY name="MajAgenda2" datasource="#session.dbname#">

      SELECT AgendaObjet FROM Agenda WHERE AgendaDateDeb=#DateSelect# GROUP BY AgendaObjet

</CFQUERY>

<CFOUTPUT>MajAgenda2.recordcount :# MajAgenda2.recordcount# </CFOUTPUT>

<CFOUTPUT query="MajAgenda2">

        <cfset AgendaObjet="#AgendaObjet#">

</CFOUTPUT>

Hello,
I try to select an item for a date with no result
Thank you for your help
cordially

    This topic has been closed for replies.

    4 replies

    BKBK
    Community Expert
    Community Expert
    June 23, 2017

    Sorry, there was an error in post. Please read 

    <cfset simpleDateFormat = createobject("java", "java.text.SimpleDateFormat").init("hh:mm")>

    If you still fail to get 10:00 you should contact the host.

    ZNBAuthor
    Inspiring
    June 23, 2017

    Résult :

    HeureSelect : 10:00 heuredeb : 10 - mindeb : 00 AgendaHeureDeb : 1899-12-30 10:00:00.0

             http://www.zennetbuilder.com/admin/Agenda_Maj.cfm?Mode=creation&DateSelect=20/06/17&HeureSelect=10:00

    always the same problem !


    I contact my web host


    Thanks to all

    Dave Ferguson
    Participating Frequently
    June 13, 2017

    Also, just an FYI.  If you are not outputting or quoting the code you don't need to put "#" signs around it.  For example...

    <cfset DateSelect=#createODBCDate(DateSelect)#>

    can be

    <cfset DateSelect = createODBCDate(DateSelect)>

    <cfset an="#Year(DateSelect)#"><cfset mois="#Month(DateSelect)#"><cfset jour="#Day(DateSelect)#">

    can be

    <cfset an= Year(DateSelect) ><cfset mois= Month(DateSelect) ><cfset jour= Day(DateSelect) >

    ZNBAuthor
    Inspiring
    June 14, 2017

    Thank you for all your advice.
    For dates, it works!
    On the other hand, I have problems now with the hours:
      Selection date: 10:00:00
    Date display: 1899-12-30 10: 00: 00.0.
    Despite a TimeDate: <cfset CalendarHeureDeb = "# Timeformat (AgendaHeureDeb, 'HH: MM') #">, nothing changes!
    Thank you for you precious help.

    EddieLotter
    Inspiring
    June 14, 2017

    What do you mean "nothing changes"?

    Please post the code where you expect to see a change.

    Cheers

    Eddie

    BKBK
    Community Expert
    Community Expert
    June 12, 2017

    ZNB  wrote

    <cfset DateSelect=16/07/2017>

    <cfset dateSelect = createDate(2017,6,17)>

    <cfset NumJour=#Dayofweek(DateSelect -1)#>

    If you wish to subtract one day, the use

    <cfset NumJour=dayOfWeek(dateadd('D',-1,DateSelect))>

    ZNBAuthor
    Inspiring
    June 13, 2017

            I now have an error message: "Syntax error in string in query expression 'CalendarDateDeb = # 11/6/2017 00: 00: 00 #" AND sitename =' SoBoat 'GROUP BY AgendaObject'. "With the following code:

         <CFOUTPUT>

           <cfset DateSelect="17/06/2017">

           <!--- <cfset DateSelect="#Dateformat(dateadd('D',m,Dim),"DD/MM/YYYY")#">  --->

           <cfset DateSelect=#createODBCDate(DateSelect)#>

           <cfset an="#Year(DateSelect)#"><cfset mois="#Month(DateSelect)#"><cfset jour="#Day(DateSelect)#">

           an : #an# - mois : #mois# - jour : #jour#

           <cfset dateSelect = #createDate(an,mois,jour)#>

           dateselect : #dateselect# --->

           </CFOUTPUT>

           

           <CFQUERY name="MajAgenda2" datasource="#session.dbname#">

            SELECT

             AgendaObjet

            FROM Agenda

            WHERE

             AgendaDateDeb=#DateSelect#"

            AND sitename='#Session.site#'

            GROUP BY AgendaObjet

           </CFQUERY>

           <!--- <CFOUTPUT>MajAgenda2.recordcount :# MajAgenda2.recordcount# - DateSelect : #DateSelect#</CFOUTPUT> --->

           <CFOUTPUT query="MajAgenda2">

            <cfset AgendaObjet="#AgendaObjet#">

           </CFOUTPUT>

    I think it comes from dates in French!
    Thank you for your help

    Inspiring
    June 13, 2017

    Its more likely the rogue " you have in the query.

    #DateSelect#"

    Remove the quote marks at the end of this.

    WolfShade
    Legend
    June 11, 2017

    Hello,

    The first thing you need to do is to CFSET the date within quotes:

    <cfset DateSelect = "16/07/2017" />

    Then use CFQUERYPARAM and CREATEODBCDATE in your query:

    <cfquery>

         SELECT AgendaObjet

         FROM Agenda

         WHERE AgendaDateDeb=<cfqueryparam value="#CreateODBCDate(DateSelect)#" />

         GROUP BY AgendaObjet

    </cfquery>

    HTH,

    ^ _ ^