Prev: Word automation (embedded)
Next: Vulcan 2.0 for VS2010
From: Stefan L on 27 Apr 2010 19:09 Hi, I Have 2 posts in a database with the field "NYKALDAT" (date) containing Post 1 = 2010-05-17 Post 2 = 2010-04-08 // Visual Objects (Version 2.8. Build 2.2828), Version 2.8 SP2 Now I try to filter the database like this: ? DTOC(Today()) // Gives "2010-04-28" ? cFilter := "NYKALDAT" + " < " + DTOC(Today()) // Gives "NYKALDAT < 2010-04-28" uCB := &("{||" + cFilter + "}") // Codeblock ? SELF:oSFSub_Form1:Server:SetFilter(uCB ,cFilter) // Gives .T. SELF:oSFSub_Form1:Server:GoTop() DO WHILE !SELF:oSFSub_Form1:Server:EOF ? SELF:oSFSub_Form1:Server:Recno // No records! Should show Post 2. SELF:oSFSub_Form1:Server:Skip() ENDDO Now I try to change the date format like this: cDate := GetDateFormat() SetDateFormat("MM.DD.YYYY") ? DTOC(Today()) // Gives "04.28.2010" ? cFilter := "NYKALDAT" + " < " + DTOC(Today()) // Gives "NYKALDAT < 04.28.2010" uCB := &("{||" + cFilter + "}") // Codeblock ? SELF:oSFSub_Form1:Server:SetFilter(uCB ,cFilter) // Gives .T. SELF:oSFSub_Form1:Server:GoTop() DO WHILE !SELF:oSFSub_Form1:Server:EOF ? SELF:oSFSub_Form1:Server:Recno // Show both records! Should only show Post 2. SELF:oSFSub_Form1:Server:Skip() ENDDO Can somebody enlighten me? If I test with a numeric field it works. Stefan L
From: Stephen Quinn on 27 Apr 2010 20:24 Stefan Try cFilter := "NYKALDAT" + " < CTOD( '" + DTOC(Today()) + "' )" // Gives "NYKALDAT < CTOD( '2010-04-28' )" The formatted date ('2010-04-28') is for visual purposes only, you have to convert it back for comparisons. CYA Steve
From: Stefan L on 27 Apr 2010 21:27 On 28 Apr, 02:24, "Stephen Quinn" <stevej...(a)bigpondSPAM.net.au> wrote: > Stefan > > Try > cFilter := "NYKALDAT" + " < CTOD( '" + DTOC(Today()) + "' )" > // Gives "NYKALDAT < CTOD( '2010-04-28' )" > > The formatted date ('2010-04-28') is for visual purposes only, you have to > convert it back for comparisons. > > CYA > Steve Thanks Stephen, Worked like a charm. Stefan
From: John Martens on 28 Apr 2010 01:44 Dtos() could also help. Op 28-4-2010 1:09, Stefan L schreef: > Hi, > > I Have 2 posts in a database with the field "NYKALDAT" (date) > containing > Post 1 = 2010-05-17 > Post 2 = 2010-04-08 > > // Visual Objects (Version 2.8. Build 2.2828), Version 2.8 SP2 > > Now I try to filter the database like this: > ? DTOC(Today()) // Gives "2010-04-28" > ? cFilter := "NYKALDAT" + "< " + DTOC(Today()) // Gives "NYKALDAT< > 2010-04-28" > uCB :=&("{||" + cFilter + "}") // Codeblock > ? SELF:oSFSub_Form1:Server:SetFilter(uCB ,cFilter) // Gives .T. > SELF:oSFSub_Form1:Server:GoTop() > > DO WHILE !SELF:oSFSub_Form1:Server:EOF > ? SELF:oSFSub_Form1:Server:Recno // No records! Should show Post > 2. > SELF:oSFSub_Form1:Server:Skip() > ENDDO > > Now I try to change the date format like this: > cDate := GetDateFormat() > SetDateFormat("MM.DD.YYYY") > > ? DTOC(Today()) // Gives "04.28.2010" > ? cFilter := "NYKALDAT" + "< " + DTOC(Today()) // Gives "NYKALDAT< > 04.28.2010" > uCB :=&("{||" + cFilter + "}") // Codeblock > ? SELF:oSFSub_Form1:Server:SetFilter(uCB ,cFilter) // Gives .T. > SELF:oSFSub_Form1:Server:GoTop() > > DO WHILE !SELF:oSFSub_Form1:Server:EOF > ? SELF:oSFSub_Form1:Server:Recno // Show both records! Should only > show Post 2. > SELF:oSFSub_Form1:Server:Skip() > ENDDO > > Can somebody enlighten me? If I test with a numeric field it works. > > Stefan L
|
Pages: 1 Prev: Word automation (embedded) Next: Vulcan 2.0 for VS2010 |