Showing posts with label couple. Show all posts
Showing posts with label couple. Show all posts

Thursday, March 29, 2012

Date range for daily job

Hi!
I have a SQL job that runs a query. That job has to be run daily (or
couple of times per day) The query has to collect information for some
created apps
WHERE DateCreated BETWEEN [First Day of Current Month at 12:00am] AND
[Right Now]. How can dynamically program the First Day of Current
Month at 12:00am. Anybody know of any function that can give me this
value no matter at what time I run that job?
Thank you,
T.T.
declare @.date datetime
-- Figure out the first day of the month
select @.date = DATEADD(DD, (DATEPART(DD, GETDATE()) - 1) * -1, GETDATE())
-- Trim off the time.
select @.date = CONVERT(DATETIME,CONVERT(VARCHAR(10), @.date, 101))
SELECT @.date
RLF
"tolcis" <nytollydba@.gmail.com> wrote in message
news:1173964963.027568.47310@.n59g2000hsh.googlegroups.com...
> Hi!
> I have a SQL job that runs a query. That job has to be run daily (or
> couple of times per day) The query has to collect information for some
> created apps
> WHERE DateCreated BETWEEN [First Day of Current Month at 12:00am] AND
> [Right Now]. How can dynamically program the First Day of Current
> Month at 12:00am. Anybody know of any function that can give me this
> value no matter at what time I run that job?
> Thank you,
> T.
>|||On Mar 15, 9:41 am, "Russell Fields" <russellfie...@.nomail.com> wrote:
> T.
> declare @.date datetime
> -- Figure out the first day of the month
> select @.date = DATEADD(DD, (DATEPART(DD, GETDATE()) - 1) * -1, GETDATE())
> -- Trim off the time.
> select @.date = CONVERT(DATETIME,CONVERT(VARCHAR(10), @.date, 101))
> SELECT @.date
> RLF
> "tolcis" <nytolly...@.gmail.com> wrote in message
> news:1173964963.027568.47310@.n59g2000hsh.googlegroups.com...
> > Hi!
> > I have a SQL job that runs a query. That job has to be run daily (or
> > couple of times per day) The query has to collect information for some
> > created apps
> > WHERE DateCreated BETWEEN [First Day of Current Month at 12:00am] AND
> > [Right Now]. How can dynamically program the First Day of Current
> > Month at 12:00am. Anybody know of any function that can give me this
> > value no matter at what time I run that job?
> > Thank you,
> > T.
Thanks. It works.

Sunday, March 11, 2012

Date formatting very flakey

We have a couple of dates displayed on our report.
The first comes from a string in our code, and I have a format
of 'mm/dd/yyyy'
The second comes from Globals!ExecutionTime, and I have a format of 'd'
These both display the way we want (which is with leading zeros) when
we stream the report to Excel.
But when we use the ReportViewer control, or when we stream the report
to html, we get strange stuff, like
00/03/2005 (s/b 09/03/2005) in the first case,
and
42/20/2005 (s/b 02/20/2006) in the second case. (Particularly
perturbing, since this is an RS global)Does using a capital m work properly? The lowercase m is for minute.
Check to see if "MM/dd/yyyy" works properly. I haven't had a problem
with the formatting and would be inetersted if this solved your
problem.
Regards,
Dan|||Ahh..much better, thanks!

Date Formatting

My problem is with the paramater format date.

My code and data in SQL are showing the date correctly as dd/mm/yyyy.

When I run report in SSRS a couple of columns show the date mm/dd/yyyy.

The format option in all cells are set to 'd'. There is no difference between the properties on these cells.

The dates themselves seem to go wrong on the date "31/12/4000" and returns them as "12/31/4000".

Any help wqould be appreciated

You need to change the report properties language setting to: English (United Kingdom). It defaults to English(United States)

Friday, February 17, 2012

Date Concatenation

Working with an archaic mess of Access dbs, and am trying to convert to a single SQL Server 2005 db.

A couple of places in the original monstrosity I have the time and date in separate columns, like the following example:

[Ticket Date] [Ticket Time]
12/1/99 0845
12/2/01 0932

One problem is the two columns can be of different data types, like a date col and a text time. If anyone knows how to bring these into a single column using SSIS, I would love to know since I have been battling with it for a while.

Use the Derived Column component. Cast them as strings and then its just a string a manipulation problem.

-Jamie