jych
asked on
First day of current month in Sybase
Hi,
I have a table is Sybase with a date field. I want to write a SQL query where I select all records where this Date Field is >= first day of the current month, so in this case, 01-NOV-2005.
Any ideas how I can accomplish this in SQL in Sybase. My date field has a time stamp as well.
Thanks.
I have a table is Sybase with a date field. I want to write a SQL query where I select all records where this Date Field is >= first day of the current month, so in this case, 01-NOV-2005.
Any ideas how I can accomplish this in SQL in Sybase. My date field has a time stamp as well.
Thanks.
This more customized for your need
declare @today datetime
select @today=getdate()
select convert(datetime, convert(char(8), dateadd(dd, 1-datepart(day,@today), @today), 112))
declare @today datetime
select @today=getdate()
select convert(datetime, convert(char(8), dateadd(dd, 1-datepart(day,@today), @today), 112))
This is how you can do that using MS SQL Server, so I assume something similar in Sybase:
Select YourDate - Day(YourDate) + 1
From YourTableName
Select YourDate - Day(YourDate) + 1
From YourTableName
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
try this
declare @today datetime
select @today=getdate()
select convert(char(8), dateadd(dd, 1-datepart(day,@today), @today), 112)