how to display intime and outtime in different columns - sql-server-2008-r2

the intime and outtime are in columns , but i need them likeI want it like this

I believe you are going to need to use the PIVOT operator. Here is another question similar to yours that has been answered.
Noel

Related

Year format from yyyy to yyyy-yyyy in postgresql

How do I update all values of a column from yyyy to yyyy-yyyy+1 format in postgresql.
Ex: 1942 to 1942-1943
I'd say that this is in general not a good idea, as it doesn't really add any value to the data. It appears you are saving these years in a text format which is already a bit of an issue but it could suit your purposes. Although it won't always sort the years the way you'd expect it to.
It's more reasonable to add this extra data when you're actually serializing the data to your users, at the place it is needed.
I recommend you to change your column data type to Date (date_field1) and create another Date column (date_field2) for this operation,
TO_DATE(date_field1, YYYY);
And then you can update your column as shown below,
UPDATE table SET date_field2 = date_field1 + interval '1 year';
Here is date column manipulation methods, hope it helps.

Newbie to HQL - Date conversions in Hive - extract Year from free flow text varchar100

I have a simple HQL statement which works. I want to be able to count the occurrence's by Year or by Month. The data Quality is not good,and the incorporationdate column is held as a varchar100 and contains free flowing text and nulls
So I cannot use Substring or YEAR as I need to only perform a extract on the format mm/dd/yyyy to pull out the Year or month. Ideally I would like to create a View and create 2 new Columns , one to show the year and one to show the month this would be the perfect scenario.
select
incorporationdate, count(incorporationdate) from default.chjp2
group by companynumber,incorporationdate
===================================================
Regards
JP
you could use if and test any condition you want before using substring:
select if(date is not null and date rlike '^\d{2}\/\d{2}\/\d{4}$', substr(7),null)

How to convert a 5 digit INT to date

I apologise if this question has been asked but I cannot find an answer that quite fits.
I have a database with dates stored as 5 digit integers. I can covert these to datetime, however the dates are showing in the future.
For example,
select convert(datetime,StartDate,103)
from dpm.Schedule
where ScheduleID like 50003;
Gives the results of
2107-05-31 00:00:00:000 but this date should actually be 26/05/2008.
I am pretty new to T-SQL and have looked for sometime to find the answer to this but I am reaching the end of my sanity.
We cannot answer because you are doing a lot of confusion. To start 5003 is the Id of the record and [StartDate] is the value you are trying to convert.
Also drop using operator LIKE in the Id
Example:
select convert(datetime,50003,103)
returns:
2036-11-26 00:00:00.000
but you are trying to convert the value returned by
select StartDate
from dpm.Schedule
where ScheduleID = 50003;
Please edit your question and show us a nice example using SQL Fiddle

DateDiff() function help - Dates in 2 different columns

I am trying to write a function to enable Tableau to calculate the difference between 2 dates, however they are in 2 different columns and I am having a bit of trouble.
Example:
Column 1
First Opened Date - 10/01/2014
Column 2
Reviewed Date - 15/01/2014
Obviously from this example there is 5 days between the two different columns.
These columns are aligned in rows due to a unique ID.
Any help would be much appreciated!
Thanks
Ellie
I am not sure exactly what your data looks like, but you could calculate the difference in days between two dates by using the datediff function.
I am using this calculation: DATEDIFF('day',[Order Date],[Ship Date])
You can easily recreate this with the sample data set (superstore) that ships with tableau.
Please use attr(DATEDIFF('day',[Order Date],[Ship Date]))
you will get the correct answer

Formatting of the caption of a chart

Does anyone of you know a way to format the caption of a chart in Crystal Reports? I have a number that stands for a specific year, this number is 4 digits long. I wnat the caption to be shown like:
2009
But the current way its shown is
2.009
EDIT:
The years are dynamically load from the database and in the DB they are stored as a datetime Field that i select by using the year function...
I don't know anything about crystal reports. You should mention that in the question title, or at least in the question itself, not just in the tags.
I suppose you could use a real DateTime object (instead of an int) for the date and use some function to format dates to display only the year. Like this guy:
For example, I need a date formatting as following:
23-Mar-2007
The following formula will do the trick:
ToText({MYFIELDNAME }, "dd-MMM-yyyy")
That relates to field names, but I suppose you can use the same function (ToText) for the caption of the chart?
You could also store the year in a string.