Results 1 to 8 of 8
  1. #1
    jgs is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2019
    Posts
    7

    Informex vs SQL date problems

    I have recently switched a large database from Informex to Windows SQL and am trying to get all my queries and reports to run correctly.



    I have a Query that works with dates:

    ptdate: IIf([pickprtdt]=1/1/1980,[trandte],[pickprtdt])

    In Informex somehow I had the output formatted as yyyymmdd. In SQL it comes out ad yyyy-mm-dd

    I tried:

    format(IIf([pickprtdt]=1/1/1980,[trandte],[pickprtdt]),yyyymmdd) and it would not run and it wants to put yyyymmdd in brackets [] - plus I didn't have to use the format command with Informex.

    I also tried entering yyyymmdd in the format section of the properties box

    I also tied to format the output in the report I run from the query - it won't let me format it

    Any suggestions?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I'm surprised it works at all without delimiters around the date. The format needs quotes around it. Try

    format(IIf([pickprtdt]=#1/1/1980#,[trandte],[pickprtdt]),"yyyymmdd")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    jgs is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2019
    Posts
    7
    Thanks. I had delimiters and took them out when I was playing around with it. I was missing the "" - sometimes it takes another set of eyes.

    I have another problem - I am trying to run this query:

    qty: Abs(IIf([qtyshp]>0,[qtyshp],[altqtyshp]))

    If quantity ship is greater than 0 (zero) - I want it to return that number. If it is 0 or less I want the alternate quantity ship - and I want absolute value with no minus signs.

    I get the Error#

    The table field would have .0000000 as an entry

    It ran fine in Informex

    Thoughts?

    Thanks.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    That looks okay offhand. You get the error on every line? That would imply a field name is spelled wrong or something. Or maybe the data type of the field being tested is text rather than numeric?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    jgs is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2019
    Posts
    7
    Yes it shows on Every Line

    Checked data type in the data base shows as "short text"

    It's not my database - and I can't change the data type. Is there a workaround for this?

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Try

    qty: Abs(IIf(CDbl(Nz([qtyshp], 0))>0,[qtyshp],[altqtyshp]))

    The Nz() function makes sure the value isn't Null, which would cause an error in the CDbl() function.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    jgs is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2019
    Posts
    7
    That worked. Thank you.

    I am familiar with NZ and its uses.

    I do not know CDbl - and after a quick search - I'm not sure I understand it - but I will figure it out.

    Thank you for our help. Saved me a lot of time banging my head against the keyboard.

    Jeb

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Happy to help. There are a number of conversion functions, each to a different data type: CInt() for Integer, CCur() for Currency, etc. I'd guess their most common use is similar to this, to take a text value and make it a numeric value.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Date Problems
    By Molly in forum Queries
    Replies: 4
    Last Post: 10-28-2018, 04:37 PM
  2. Problems with Date Range Parameters in query
    By ethornto2346 in forum Queries
    Replies: 3
    Last Post: 06-23-2015, 10:06 AM
  3. Problems with date range in query
    By pbaccess in forum Access
    Replies: 1
    Last Post: 02-18-2014, 04:54 AM
  4. Replies: 11
    Last Post: 03-21-2012, 12:51 PM
  5. Date Query Problems
    By 97rstd in forum Queries
    Replies: 1
    Last Post: 12-09-2011, 11:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums