Ms Access Syntax issues - sql

My problem is that I would like to realize this, but it throws syntax error.
WorkDayUltimate: Format(DateAdd("mm/dd/yy","h",-6,[Outgoing Date])
Thanks for your help in advance.

You must first add to date, then format:
WorkDayUltimate: Format(DateAdd("h",-6,[Outgoing Date]),"mm/dd/yy")

Related

Microsoft SQL error in string for wrong syntax

First time posting on here.
Please can someone help me with this very simple error that I cannot seem to fix.
if #DivResult > 0 and #IfMenu = ('A','F')
There is a syntax error near the comma
This is not valid tsql syntax: and #IfMenu = ('A','F')
The correct would be: and #IfMenu in ('A','F')

VB.NET - LINQ - dbContext - Where - Letter is not declared error. Trying to update single record

I'm in the process of writing an update code to update user information on an asset used for a project I have. The code is below...
AlteredUser = dbContext.Assets.Where(c >= c.ParentAssetID = ParentAssetId And c.AssetDecription = "USER").SingleOrDefault()
AlteredUser.AssetName = UserName
dbContext.SubmitChanges()
I'm getting an error message saying " 'c' is not declared ". I've seen several examples of how to use the where clause within dbContext, and all of them use a letter as LINQ normally does. I cannot figure out why it is erroring out for me.
Any help would be greatly appreciated.
Thank you!
>= is a comparison operator.
To create a lambda in VB, write
Function(c) c....

syntax error using convert function

I'm trying to convert a timestamp into yyyymm format, and have found that this should do the trick:
select convert(nvarchar(6),getnow(),112);
I try to run this just as a POC that it will return in the proper format, but I get the following error:
ERROR: 42601: syntax error at or near ","
It works fine when I take out the style argument, but obviously does not return the desired format. I have no idea what could be happening and any help would be greatly appreciated.
Thanks!
I don't know if Redshift allow to format like SQL Server does.
So I suggest you to try with datepart. Something like this:
SELECT CONVERT(NVARCHAR(6), DATE_PART(y, getnow()) || DATE_PART(mon, getnow()) )
In SQL Server, it's getdate()...
select convert(nvarchar(6),getdate(),112)
This is the equivalent in Redshift:
select to_char(sysdate,'YYYYMM')

Adding a number to a column with a value in it Access

Ok So I have A column with a count IIF expressions As shown:
UNTESTED: Count(IIf([TEST]="UNTESTED",1))
What I want to do is now look at where the location was and when the test was done and if in a specific location and YEAR then add 8 to that value I am now trying to use:
UNTESTED: Count(IIf([TEST]="UNTESTED",1)) AND IIf([REGION]="CANADA" And [YEAR]<=2012,[UNTESTED]+8,[UNTESTED])
Thanks in advance if you can solve this!
Here is the Answer to my question, I solved it :
IIf([Site]="CANADA" Or [Site]="ALASKA",IIf([Year]<"2013",Count(IIf([Pass_Fail]="UNTESTED",1))+8,
Count(IIf([Pass_Fail]="UNTESTED",1))),Count(IIf([Pass_Fail]="UNTESTED",1)))

Access SQL for sorting by date with TempVars

im trying to make a query from the use of TempVars
im Using SQL to run the query but every time i try, it return Invalid date value
this is the line that will not work
this returns error
WHERE ((([Table].[Issue Date])>=#[TempVars]![tmpDateFrom]# And ([Table].[Issue Date])>=#[TempVars]![tmpDateTo]#));
this returns fine
WHERE ((([Table].[Issue Date])>=#10/12/12# And ([Table].[Issue Date])>=#11/12/12#));
I have checked the TempVars [tmpDateFrom] and [tmpDateTo] and they out put the date value i need.
Please help
Thank you all or the help.
due to the requirement of the database #Nicarus had the right answer this is the solution for those still wondering.
WHERE ((([Table].[Issue Date])>=[TempVars]![tmpDateFrom] And ([Table].[Issue Date])>=[TempVars]![tmpDateTo]));