Data Formating In Query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Soulspike
    New Member
    • Jan 2008
    • 35

    Data Formating In Query

    Hello all I have a little formating problem. I have a query with the following code for one of the fields

    Code:
    IIf(DatePart("ww",[InitShoppingWO]![WORDER_OUTSHOP_DATE],2,2)=53,"1", 
    (DatePart("ww",[InitShoppingWO]![WORDER_OUTSHOP_DATE],2,2)))
    This code should generate a number and allow me to use greater then less then to find groups of Fiscal Weeks. The problem is that access is seeing the result of this code as text so my searches are messed.

    Is there a way to tell access what format I want the output to be?

    Thanks
    Last edited by Scott Price; Mar 19 '08, 12:10 AM. Reason: broke long code into two lines
  • MindBender77
    New Member
    • Jul 2007
    • 233

    #2
    Originally posted by Soulspike
    Hello all I have a little formating problem. I have a query with the following code for one of the fields

    Code:
    IIf(DatePart("ww",[InitShoppingWO]![WORDER_OUTSHOP_DATE],2,2)=53,
    "1",(DatePart("ww",[InitShoppingWO]![WORDER_OUTSHOP_DATE],2,2)))
    This code should generate a number and allow me to use greater then less then to find groups of Fiscal Weeks. The problem is that access is seeing the result of this code as text so my searches are messed.

    Is there a way to tell access what format I want the output to be?

    Thanks
    You can use "Format" to modify the data type.

    See this link for more help: Formatting

    Bender
    Last edited by Scott Price; Mar 19 '08, 12:11 AM. Reason: broke long code into two lines

    Comment

    • Scott Price
      Recognized Expert Top Contributor
      • Jul 2007
      • 1384

      #3
      You can also use one of the convert functions: CInt() changes to Integer, CLng() to Long Integer, etc.

      Regards,
      Scott

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32656

        #4
        My system's playing up so I can't check this, but the true part of your IIf() is a string literal ("1"). This probably convinces Access to treat the result as a string value. If you change this to be simply 1 then i suspect the value would resolve to a number.

        Comment

        Working...