Getting DateTime
Hi ,
can you tell me how to get the Date and Time of different system which is there in the same network.
thanx in advance
Srinath.
Hi,
I didnt get you, exactly what are you looking for.
Because, date and time are same for all the systems in specific region(LAN).
this can be achieved in different ways:
For example:#
DateFormat df = new SimpleDateFormat("yyyyMMdd");
Date d = new Date();
String today = df.formt(d);
System.out.println(today);
or
String[] ids = TimeZone.getAvailableIDs(1 * 60 * 60 * 1000);
SimpleTimeZone edt = new SimpleTimeZone(1 * 60 * 60 * 1000, ids[0]);
edt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
edt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
Calendar calendar = new GregorianCalendar(edt);
Date trialTime = new Date();
calendar.setTime(trialTime);
year = Integer.toString(calendar.get(Calendar.YEAR));
month = Integer.toString(calendar.get(Calendar.MONTH)+1);
day = Integer.toString(calendar.get(Calendar.DAY_OF_MONTH));
currentdate = year+month+day;
System.out.println(currentdate);
bye
Similar Messages
-
How to get DATETIME value in a page?
Hi,
I have two pages.
In page1, I have a table that contain MessageStyleText item(AuditTime) and the attribute data type is DATETIME .
I want to pass AuditTime value from page1 to page2.
I am passing the AuditTime value from page1 to page2 using Destination URI.
The AuditTime value is 2008-11-11 12:45:31.0
How to get the AuditTime in page2 so that I can get the exact value '2008-11-11 12:45:31.0' ?
Please help.
Thanks & Regards,
SagarikaHi
I am passing the value using the following destination URI,
OA.jsp?page=/uttara/oracle/apps/uttaraimc/audit/webui/Page2&auditTime={@AuditTime}&retainAM=Y
In the database the AuditTime value is like '2008-11-11 12:45:31.0'
Normally we are using pageContext.getParameter("auditTime"); to get the value which are passed in destination URI.
Here if I'll use pageContext.getParameter("auditTime"); I am not getting the correct value.
How to get the exact value?
Thanks & Regards,
Sagarika -
Get datetime in 1st row of another column
Hi Everyone,
Please anyone help me...
Below is the query and output.
Query:
SELECT
WMUMF.BIZDOCTYPEDEF.TYPENAME,
Table__52.BD_PARTNERORDERNUMBER,
Table__67.BD_TRACKINGNUMBER,
WMUMF.BIZDOCATTRIBUTE.STRINGVALUE,
TO_DATE(TO_CHAR(WMUMF.BIZDOC.DOCTIMESTAMP,'MM/DD/YYYY HH24:MI:SS'),'MM/DD/YYYY HH24:MI:SS')
FROM
WMUMF.PARTNER SENDER,
WMUMF.PARTNER RECEIVER,
WMUMF.BIZDOCTYPEDEF,
WMUMF.BIZDOC,
SELECT
WMUMF.BIZDOCARRAYATTRIBUTE.DOCID,
WMUMF.BIZDOCARRAYATTRIBUTE.STRINGVALUE BD_PartnerOrderNumber
FROM
WMUMF.BIZDOCATTRIBUTEDEF BIZDOCATTRIBUTEDEF_A1,
WMUMF.BIZDOCARRAYATTRIBUTE
WHERE
WMUMF.BIZDOCARRAYATTRIBUTE.ATTRIBUTEID=BIZDOCATTRIBUTEDEF_A1.ATTRIBUTEID AND
Bizdocattributedef_A1.Attributename In ( 'BD_PartnerOrderNumber' )
) Table__52,
SELECT
WMUMF.BIZDOCARRAYATTRIBUTE.DOCID,
WMUMF.BIZDOCARRAYATTRIBUTE.STRINGVALUE BD_TrackingNumber
FROM
WMUMF.BIZDOCATTRIBUTEDEF BIZDOCATTRIBUTEDEF_A1,
WMUMF.BIZDOCARRAYATTRIBUTE
WHERE
WMUMF.BIZDOCARRAYATTRIBUTE.ATTRIBUTEID=BIZDOCATTRIBUTEDEF_A1.ATTRIBUTEID AND
Bizdocattributedef_A1.Attributename In ( 'BD_TrackingNumber' )
) Table__67,
WMUMF.BIZDOCATTRIBUTEDEF,
SELECT
WMUMF.BIZDOCARRAYATTRIBUTE.DOCID,
WMUMF.BIZDOCARRAYATTRIBUTE.STRINGVALUE BD_SiteID
FROM
WMUMF.BIZDOCATTRIBUTEDEF BIZDOCATTRIBUTEDEF_A1,
WMUMF.BIZDOCARRAYATTRIBUTE
WHERE
WMUMF.BIZDOCARRAYATTRIBUTE.ATTRIBUTEID=BIZDOCATTRIBUTEDEF_A1.ATTRIBUTEID AND
Bizdocattributedef_A1.Attributename In ( 'BD_SiteID' )
) Table__44
WHERE
( WMUMF.BIZDOC.DOCTYPEID=WMUMF.BIZDOCTYPEDEF.TYPEID )
AND ( WMUMF.BIZDOC.RECEIVERID=RECEIVER.PARTNERID )
AND ( SENDER.PARTNERID=WMUMF.BIZDOC.SENDERID )
AND ( WMUMF.BIZDOC.DOCID=WMUMF.BIZDOCATTRIBUTE.DOCID )
AND ( WMUMF.BIZDOCATTRIBUTEDEF.ATTRIBUTEID=WMUMF.BIZDOCATTRIBUTE.ATTRIBUTEID )
AND ( Table__44.DOCID(+)=WMUMF.BIZDOC.DOCID )
AND ( WMUMF.BIZDOC.DOCID=Table__46.DOCID(+) )
AND ( WMUMF.BIZDOC.DOCID=Table__52.DOCID(+) )
AND ( WMUMF.BIZDOC.DOCID=Table__67.DOCID(+) )
AND
WMUMF.BIZDOCTYPEDEF.TYPENAME IN ( 'doc_Xml_HoldReleaseNotification_CustomXML_Cisco','doc_Xml_PIP_3A9CancellationRequest_V_11_01' )
AND
SENDER.CORPORATIONNAME = 'CISCO LSS (E2Open)'
AND
RECEIVER.CORPORATIONNAME = 'FLEXTRONICS'
AND
WMUMF.BIZDOCATTRIBUTEDEF.ATTRIBUTENAME = 'ApplicationMessageType'
AND
WMUMF.BIZDOCATTRIBUTE.STRINGVALUE IN ( 'H','R','3A9V11.01.00' )
AND
Table__44.BD_SITEID = '027'
AND
WMUMF.BIZDOC.DOCTIMESTAMP >= TO_DATE('06/15/2013','MM/DD/YYYY')
AND WMUMF.BIZDOC.DOCTIMESTAMP <= SYSDATE+1
Output:
PartnerOrderNumber
DateTime
StringValue
Tracking Number
Document
PO1
1 am
H
123
DOC
PO1
2 am
H
246
DOC
PO1
3 am
R
125
DOC
PO1
4 am
H
678
DOC
PO2
5 am
H
890
DOC
PO2
6 am
R
098
DOC
PO2
7 am
H
001
DOC
PO2
8 am
R
870
DOC
PO3
9 am
H
008
DOC
PO3
10 am
H
065
DOC
PO3
11 am
R
593
DOC
PO3
12 pm
H
636
DOC
PO3
1 pm
H
978
DOC
PO3
2 pm
R
675
DOC
But I need like below...
PartnerOrderNumber
H DateTime
R DateTime
Tracking Number
Document
PO1
1 am
3 am
123
DOC
PO1
2 am
246
DOC
PO2
4 am
6 am
678
DOC
PO2
5 am
890
DOC
PO2
7 am
8 am
001
DOC
PO3
9 am
11 am
008
DOC
PO3
10 am
065
DOC
PO3
12 pm
2 pm
636
DOC
PO3
1 pm
978
DOC
My aim is to get H datetime in one column and R datetime in another column but only in 1st row of H datetime. PO3 has H H R H H R so each R datetime should be in 1st of H datetime.
Thanks in Advance,
SindhuThis forum is for the SQL Developer tool, not for general SQL or PL/SQL questions. The clue is in the name.
Try asking in the Database General or SQL and PL/SQL forums. -
How to get DateTime from PI message SOAP Header
Hi ALL
Can you please let me know how we can get the time message received in PI from the SOAP message header
<SAP:TimeSent>2010-08-17T16:24:16Z</SAP:TimeSent>
I would like to capture this value and send it in the payload of the message, initially I was using the Current TIme date function.
However, if I can get the time received value from the SOAP Header message, It will be more accurate in providing the Time the message was received by IE.
Thank you,
Parikshit
Sample SOAP Header from MONI:-
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- <!-- Call Adapter
-->
- <SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SAP="http://sap.com/xi/XI/Message/30">
- <SOAP:Header>
- <SAP:Main xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" versionMajor="003" versionMinor="000" SOAP:mustUnderstand="1" wsu:Id="wsuid-main-92ABE13F5C59AB7FE10000000A1551F7">
<SAP:MessageClass>ApplicationMessage</SAP:MessageClass>
<SAP:ProcessingMode>asynchronous</SAP:ProcessingMode>
<SAP:MessageId>4C69D4B7-9806-0162-E100-80000A8221E6</SAP:MessageId>
<SAP:TimeSent>2010-08-17T16:24:16Z</SAP:TimeSent>
- <SAP:Sender>If you want to get the TimeSent from SOAP header and map it to some field in ur message then u can easily do it using following UDF :-
GlobalContainer globalContainer;globalContainer = container.getGlobalContainer();
java.util.Map param = globalContainer.getParameters();.
String timeSent = (String) param.get (StreamTransformationConstants.TIME_SENT);
return timeSent ;
Note: This UDF won't need any input. So u need not to maintain any variable in UDF signature.
Edited by: Samiullah Qureshi on Aug 18, 2010 9:41 AM -
Hi,
I am working with modem TC65:
- Platform: CLDC/MIDP
- Emulator: Siemens IMP-NG TC65 R2 Wireless Toolkit
- Device: IMP_NG_TC65_R2
- Device configuration: CLDC-1.1
- Device Profile: IMP-NG
I am having a problem to get the current date time (without sending a command to modem TC65). Because it does not support both: java.util.Calendar & java.util.Date.
If anyone has worked with this device (or relevant), could you please help me?
Thanks in advance.
Your help is much appreciated!Please ignore this,
I found the answer, there is java.util.Date class existing but I could not know it.
Thanks anyway -
Get datetime to a JFrame...
i need to get the current system date & time to JFrame (to display)...also it should change dynamically according to the systems date&time
(i.e it should change from second to second...)
i tried it with a JApplet (call the JApplet in-side the JFrame...)
Like this...
//JApplet
String lastTime = "";
GregorianCalendar day = new GregorianCalendar();
String time = day.getTime().toString();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// do nothing
lastTime = time;
repaint();
//JFrame
BorderLayout bord=new BorderLayout();
getContentPane().setLayout(bord);
appletTest aT=new appletTest(); //instance from JApplet
getContentPane().add("Center",aT);
But, here it is not erase the previous value...It just overlap...
(if seconds...2 is overlap with 1....then 3 is overlap with 2)
How to avoid this...
OR
Is there other way of get the date&time to a JFrame.
pls...tell
thanksimport javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.*;
import java.util.*;
import java.applet.*;
<Applet code=AppletDate.class width=500 height=400>
</Applet>
public class AppletDate extends Applet implements Runnable
GregorianCalendar cal;
Thread thread=null;
Date date;
public void start()
if(thread==null)
thread=new Thread(this);
thread.start();
}//start
public void run()
while(thread!=null)
repaint();
try
thread.sleep(1000);
catch (Exception E)
System.out.println(E);
}//catch
}//while
}//run
public void paint(Graphics g)
String time;
date=new Date();
GregorianCalendar cal=new GregorianCalendar();
cal.setTime(date);
time=cal.get(cal.HOUR)+":"+cal.get(cal.MINUTE)+":"+cal.get(cal.SECOND);
g.drawString(time,30,30);
} -
Hi,
Is there a way to convert
23APR15
to a datetime? I got one exception to such codes
dt1 = DateTime.ParseExact(curr_dt, "DDMMMYY", null);
worksheet.Cells[rw, 1] = dt1.ToString("mm/dd/yyyy");
Many Thanks & Best Regards, Hua MinHi HuaMin,
Do you mean this error? Here is my screenshot on my side when reproduce your code,
There is no "DDMMMYY" format in DateTime. You can refer to
Standard Date and Time Format Strings for more detailed information.
The following code make sense.
DateTime.Now.ToString("yyyyMMddHHmmss"); // case sensitive
In addition, here is a pattern for en-us culture.
Specifier
DateTimeFormatInfo property
Pattern value (for en-US culture)
t
ShortTimePattern
h:mm tt
d
ShortDatePattern
M/d/yyyy
T
LongTimePattern
h:mm:ss tt
D
LongDatePattern
dddd, MMMM dd, yyyy
f
(combination of D and t)
dddd, MMMM dd, yyyy h:mm tt
F
FullDateTimePattern
dddd, MMMM dd, yyyy h:mm:ss tt
g
(combination of d and t)
M/d/yyyy h:mm tt
G
(combination of d and T)
M/d/yyyy h:mm:ss tt
m, M
MonthDayPattern
MMMM dd
y, Y
YearMonthPattern
MMMM, yyyy
r, R
RFC1123Pattern
ddd, dd MMM yyyy HH':'mm':'ss 'GMT' (*)
s
SortableDateTimePattern
yyyy'-'MM'-'dd'T'HH':'mm':'ss (*)
u
UniversalSortableDateTimePattern
yyyy'-'MM'-'dd HH':'mm':'ss'Z' (*)
(*) = culture independent
Best regards,
Kristin
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Finding datetime gaps:
we have a table with cars working from to dates:
rec car DateFrom DateTo
1 11 2008-10-28 00:00:00 2008-11-05 23:59:59
2 11 2008-11-06 00:00:00 2008-11-08 23:00:00
3 11 2008-11-09 00:00:00 2008-11-05 23:59:59
4 22 2008-10-28 00:00:00 2008-10-29 20:00:00
5 22 2008-10-31 00:00:00 2008-11-05 23:59:59
result I'm lookin for is finding dates and delta time a car is not working:
car gapFrom gapTo gapDelta[h]
11 2008-11-08 23:00:00 2008-11-09 00:00:00 1 (in hours)
22 2008-10-29 20:00:00 2008-10-31 00:00:00 28Hi b_blase,
Please see the below code to retrieve datetime delta gaps.
CREATE TABLE yourTable
rec INT,
car INT,
dateFrom DATETIME,
dateTo DATETIME
INSERT INTO yourTable VALUES(1,11,'2008-10-28 00:00:00','2008-11-06 00:00:00'),
(2,11,'2008-11-06 00:00:00','2008-11-08 23:00:00'),
(3,11,'2008-11-09 00:00:00','2008-11-10 00:00:00'),
(4,11,'2008-11-10 11:37:00','2008-11-11 00:00:00'),
(5,22,'2008-10-28 00:00:00','2008-10-29 20:00:00'),
(6,22,'2008-10-31 00:00:00','2008-11-05 00:00:00'),
(7,22,'2008-11-07 00:00:00','2008-11-11 00:00:00');
;WITH CTE AS
SELECT *,ROW_NUMBER() OVER(PARTITION BY car ORDER BY dateFrom) AS rn FROM yourTable
CTE2 AS
SELECT c1.car car,c2.dateTo gapFrom, c1.dateFrom gapTo
FROM CTE c1 LEFT JOIN CTE c2
ON c1.rn=c2.rn+1 AND c1.car=c2.car
WHERE c1.dateFrom <> c2.dateTo
SELECT *,CAST(ROUND(DATEDIFF(MINUTE,gapFrom,gapTo)/60.0,2) AS NUMERIC(20,1)) gapDelta FROM CTE2 ORDER BY car,gapTo;
DROP TABLE yourTable;
I just made a little modification on the dateTo column so that the
dateTo equaling to the dateFrom of next record can be identified as no gap. If you still prefer the dateTo valuing like ‘2008-11-06 23:59:59‘ as it was, you just modify the WHERE clause as below.
WHERE DATEDIFF(MINUTE,c2.dateTo,c1.dateFrom) <> 1
If you have any question, feel free to let me know.
Best regards,
Eric Zhang -
DateTime issue at Universe Level
Hello Experts,
We have stored date in database as datetime format. In Universe, we have created object on this date. But we have to keep type of this objet as u2018Dateu2019 as there is no datetime object type available in universe.
When we dragged this objet in webi, we found that we are getting only date but no timestamp. We can manually do this using report formatting. However we would like to achive this at universe level.
My question is : What should be the type of object in universe for getting datetime at report level ?
We found that, if we keep objet type as char, we may get the desired results. However is there any other alternative?
Regards,
ChinmayHi,
Use the Function Convert to convert into datetime format in the Universe object level.
Syntax:
convert(datetime,field_name,101)
Regards,
Shiva Kumar G.C -
Composite control - change text property of textbox from .cs file
Hi All,
I have created a composite control with dropdowns and hiddenfield for datepicker. Now when I change the value of dropdown from browser - client side then its value is retained on postback. But when I change value programmatically its not reflected on
screen.
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.ComponentModel;
using System.Drawing;
using System.Web;
using System.Web.UI;
using System.Web.UI.Design;
using System.Web.UI.WebControls;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;
namespace GOV.Framework.Portal.Controls
/// <summary>
/// Simple DateTimePicker control that uses jQuery UI DatePicker to pop up
/// a date, time or both picker.
/// </summary>
[ToolboxBitmap(typeof(System.Web.UI.WebControls.Calendar)), DefaultProperty("SelectedValue"),
ToolboxData("<{0}:DateTimePicker runat=\"server\"></{0}:DateTimePicker>"), PersistenceMode(PersistenceMode.InnerProperty)]
public class DateTimePicker : WebControl
#region "Global Variables"
public enum DisplayControls
TextBox,
Dropdown
public enum DisplayModes
Button,
ImageButton,
AutoPopup,
Inline,
public enum DisplayTypes
Time,
Date,
DateTime
public enum DisplayMonthTypes
Full,
Short
private enum DisplayYearTypes
Full,
Short
private DropDownList ddlDay = new DropDownList();
private DropDownList ddlMonth = new DropDownList();
private DropDownList ddlYear = new DropDownList();
private TextBox txtDate = new TextBox();
private Label lblMsg = new Label();
private System.Web.UI.WebControls.Image imgCal = new System.Web.UI.WebControls.Image();
private HiddenField hdnDate = new HiddenField();
private DisplayModes _DisplayMode = DisplayModes.ImageButton;
private DisplayControls _DisplayControl = DisplayControls.TextBox;
private DisplayTypes _DisplayType = DisplayTypes.DateTime;
private int _StepMinutes = 1;
private int _StepHours = 1;
private DateTime? _MinDate = null;
private DateTime? _MaxDate = null;
private string _OnClientSelect = "";
private string _ButtonImage = "../Images/calendar.png";
private string _CalendarCss = "WebResource";
private string _CalendarJs = "../scripts/timepicker.js";
private DisplayMonthTypes _DisplayMonthType = DisplayMonthTypes.Full;
private DisplayYearTypes _DisplayYearType = DisplayYearTypes.Full;
private int _minYear = DateTime.Now.Year - 25;
private int _maxYear = DateTime.Now.Year;
private int _minMonth = 1;
private int _maxMonth = 31;
private int _minDay = 1;
private int _maxDay = 28;
private string _dateControlClientId = string.Empty;
DateTime? _SelectedDate = null;
private bool _DisplayMessageLabel = true;
private short _tabIndex;
private const string vwst_SelectedDate = "_SelectedDate";
#region "ErrorMessages"
private const string SelectedDate_GreaterThan_MaxDate = "SelectedDate can not be greater than MaxDate";
private const string MaxDate_LessThan_SelectedDate = "MaxDate can not be less than SelectedDate";
private const string SelectedDate_LessThan_MinDate = "SelectedDate can not be less than MinDate";
private const string MinDate_GreaterThan_SelectedDate = "MinDate can not be greater than SelectedDate";
#endregion
#endregion
#region "Properties"
#region "Private Properties"
[Description("Determines display full or short(yy) year")]
[Category("DateTime Selection"), DefaultValue(typeof(DisplayTypes), "string")]
private DisplayYearTypes DisplayYearType
get
return _DisplayYearType;
set
_DisplayYearType = value;
[Description("Determines minimum year to be displayed in dropdown : Default currentyear - 25")]
[Category("DateTime Selection"), DefaultValue(typeof(DisplayTypes), "int")]
private int MinYear
get
if (MinDate != null)
_minYear = MinDate.Value.Year;
else
_minYear = DateTime.Now.Year - 25;
return _minYear;
//set
// _minDisplayYear = value;
[Description("Determines maximum year to be displayed in dropdown : Default currentyear")]
[Category("DateTime Selection"), DefaultValue(typeof(DisplayTypes), "int")]
private int MaxYear
get
if (MaxDate != null)
_maxYear = MaxDate.Value.Year;
else
_maxYear = DateTime.Now.Year;
return _maxYear;
//set
// _maxDisplayYear = value;
private string DateControlClientId
get
if (DisplayControl == DisplayControls.Dropdown)
_dateControlClientId = hdnDate.ClientID;
else
_dateControlClientId = txtDate.ClientID;
return _dateControlClientId;
[Description("Determines minimum month of min date : default 1")]
[Category("DateTime Selection"), DefaultValue(1)]
private int minMonth
get
if (MinDate != null)
_minMonth = MinDate.Value.Month;
else
_minMonth = 1;
return _minMonth;
[Description("Determines max months of max date: Default 12")]
[Category("DateTime Selection"), DefaultValue(12)]
private int maxMonth
get
if (MaxDate != null)
_maxMonth = MaxDate.Value.Month;
else
_maxMonth = 1;
return _maxMonth;
[Description("Determines minimum day : Defualt 1")]
[Category("DateTime Selection"), DefaultValue(1)]
private int minDay
get
if (MinDate != null)
_minDay = MinDate.Value.Day;
else
_minDay = 1;
return _minDay;
[Description("Determines max day: Defualt last day of max month")]
[Category("DateTime Selection"), DefaultValue(30)]
private int maxDay
get
if (MaxDate != null)
_maxDay = MaxDate.Value.Day;
else
_maxDay = DateTime.DaysInMonth(MaxYear, maxMonth);
return _maxDay;
#endregion
#region "Public Properties"
/// <summary>
/// The currently selected datetime
/// </summary>
[Category("DateTime Selection")]
public DateTime? SelectedValue
get
DateTime dt = new DateTime();
if (DisplayControl == DisplayControls.TextBox && txtDate.Text != "")
DateTime.TryParse(txtDate.Text, out dt);
else if (DisplayControl == DisplayControls.Dropdown && hdnDate.Value != "")
DateTime.TryParse(hdnDate.Value, out dt);
if (dt != null && dt != new DateTime())
_SelectedDate = dt;
else
_SelectedDate = null;
return _SelectedDate;
set
if (!value.HasValue)
txtDate.Text = "";
hdnDate.Value = "";
else
if (value != null && MinDate != null && value < MinDate)
throw new ArgumentOutOfRangeException("SelectedValue", SelectedDate_LessThan_MinDate);
if (value != null && MaxDate != null && value > MaxDate)
throw new ArgumentOutOfRangeException("SelectedValue", SelectedDate_GreaterThan_MaxDate);
string dateFormat = this.DateTimeFormat;
//if ( dateFormat == "Auto")
// dateFormat = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
if (DisplayControl == DisplayControls.TextBox)
txtDate.Text = value.Value.ToString(dateFormat);
else if (DisplayControl == DisplayControls.Dropdown)
hdnDate.Value = value.Value.ToString(dateFormat);
_SelectedDate = value;
if (DisplayControl == DisplayControls.Dropdown)
setDropDownValue(value);
[Description("Determines display textbox or dropdowns")]
[Category("DateTime Selection"), DefaultValue(typeof(DisplayModes), "TextBox")]
public DisplayControls DisplayControl
get { return _DisplayControl; }
set { _DisplayControl = value; }
[Description("Determines how the datepicking option is activated")]
[Category("DateTime Selection"), DefaultValue(typeof(DisplayModes), "ImageButton")]
public DisplayModes DisplayMode
get { return _DisplayMode; }
set { _DisplayMode = value; }
[Description("Determines what datetimepicker should return")]
[Category("DateTime Selection"), DefaultValue(typeof(DisplayTypes), "DateTime")]
public DisplayTypes DisplayType
get
return _DisplayType;
set
_DisplayType = value;
[Description("Increment minute factor when using the time picker.")]
[Category("DateTime Selection"), DefaultValue(1)]
public int StepMinutes
get
return _StepMinutes;
set
_StepMinutes = value;
[Description("Increment hour factor when using the time picker.")]
[Category("DateTime Selection"), DefaultValue(1)]
public int StepHours
get
return _StepHours;
set
_StepHours = value;
private string _DateTimeFormat = CultureInfo.CurrentCulture != null ? CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern : "dd/MM/yyyy";
[Description("Determines the Date Format used. Auto uses CurrentCulture.DateTimeFormat.ShortDatePattern. Format: MM month, dd date, yyyy year symbol")]
[Category("DateTime Selection"), DefaultValue("dd/MM/yyyy")]
public string DateTimeFormat
get
return _DateTimeFormat;
set
_DateTimeFormat = value;
[Description("Minumum allowable date. Leave blank to allow any date")]
[Category("DateTime Selection"), DefaultValue(typeof(DateTime?), null)]
public DateTime? MinDate
get
return _MinDate;
set
if (value != null && SelectedValue != null && value > SelectedValue)
throw new ArgumentOutOfRangeException("MinDate", MinDate_GreaterThan_SelectedDate);
_MinDate = value;
[Description("Maximum allowable date. Leave blank to allow any date.")]
[Category("DateTime Selection"), DefaultValue(typeof(DateTime?), null)]
public DateTime? MaxDate
get
return _MaxDate;
set
if (value != null && SelectedValue != null && value < SelectedValue)
throw new ArgumentOutOfRangeException("MaxDate", MaxDate_LessThan_SelectedDate);
_MaxDate = value;
[Description("Client event handler fired when a date is selected")]
[Category("DateTime Selection"), DefaultValue("")]
public string OnClientSelect
get
return _OnClientSelect;
set
_OnClientSelect = value;
[Description("Url to a Calendar Image. Applies only if the DisplayMode = ImageButton")]
[Category("DateTime Resource"), DefaultValue("../Images/calendar.png")]
public string ButtonImage
get { return _ButtonImage; }
set { _ButtonImage = value; }
[Category("DateTime Resource"), Description("The CSS that is used for the calendar or empty for default."), DefaultValue("WebResource")]
public string CalendarCss
get { return _CalendarCss; }
set { _CalendarCss = value; }
[Description("Location for the calendar JavaScript or empty for default.")]
[Category("DateTime Resource"), DefaultValue("../scripts/timepicker.js")]
public string CalendarJs
get { return _CalendarJs; }
set { _CalendarJs = value; }
[Description("Determines what to Display full Month name or short month name")]
[Category("DateTime Selection"), DefaultValue(typeof(DisplayTypes), "string")]
public DisplayMonthTypes DisplayMonthType
get
return _DisplayMonthType;
set
_DisplayMonthType = value;
[Description("Display static label for msg below date control")]
[Category("DateTime Selection"), DefaultValue(true)]
public bool DisplayMessageLable
get { return _DisplayMessageLabel; }
set { _DisplayMessageLabel = value; }
[Bindable(true)]
[DefaultValue("false")]
public override short TabIndex
get
return _tabIndex;
set
_tabIndex = value;
ddlDay.TabIndex = value;
ddlMonth.TabIndex = value;
ddlYear.TabIndex = value;
imgCal.TabIndex = value;
#endregion
#endregion
#region "Events"
public DateTimePicker()
this.Width = Unit.Pixel(80);
/// <summary>
/// Load all controls
/// </summary>
/// <param name="e"></param>
protected override void OnInit(EventArgs e)
base.OnInit(e);
//Controls.Clear();
//CreateAndAddControls();
/// <summary>
/// Add Child controls - Dropdowns and textbox;
/// </summary>
protected override void CreateChildControls()
base.CreateChildControls();
Controls.Clear();
CreateAndAddControls();
/// <summary>
/// Load all controls
/// </summary>
/// <param name="e"></param>
protected override void OnLoad(EventArgs e)
base.OnLoad(e);
if (DisplayControl == DisplayControls.Dropdown)
if (ddlDay.Items.Count == 0 || ddlMonth.Items.Count == 0 || ddlYear.Items.Count == 0 || !Page.IsPostBack)
FillDropdowns();
generateDisplayMessage();
protected override void LoadViewState(object savedState)
base.LoadViewState(savedState);
protected override void LoadControlState(object savedState)
base.LoadControlState(savedState);
protected override object SaveViewState()
if (HasControls() && Page.IsPostBack)
ddlDay.SelectedValue = "11";
object obj = base.SaveViewState();
return obj;
protected override void TrackViewState()
base.TrackViewState();
/// <summary>
/// Most of the work happens here for generating the hook up script code
/// </summary>
/// <param name="e"></param>
protected override void OnPreRender(EventArgs e)
base.OnPreRender(e);
// Register resources
this.RegisterResources();
string script = GenerateScript();
Page.ClientScript.RegisterStartupScript(this.GetType(), "_cal" + this.ID, script, true);
/// <summary>
/// Render Control
/// </summary>
/// <param name="writer"></param>
public override void RenderControl(HtmlTextWriter writer)
if (this.DisplayMode != DisplayModes.Inline)
base.RenderControl(writer);
else
writer.Write("<div id='" + this.ClientID + "Div'></div>");
if (HttpContext.Current == null)
if (this.DisplayMode == DisplayModes.Button)
writer.Write(" <input type='button' value='...' style='width: 20px; height: 20px;' />");
else if ((this.DisplayMode == DisplayModes.ImageButton))
string img;
if (this.ButtonImage == "WebResource")
img = this.Page.ClientScript.GetWebResourceUrl(this.GetType(), "jQueryDatePicker.Resources.calendar.png");
else
img = this.ResolveUrl(this.ButtonImage);
writer.AddAttribute(HtmlTextWriterAttribute.Src, img);
writer.AddAttribute("hspace", "2");
writer.RenderBeginTag(HtmlTextWriterTag.Img);
writer.RenderEndTag();
/// <summary>
/// Render Control
/// </summary>
/// <param name="writer"></param>
protected override void Render(HtmlTextWriter writer)
RenderControls(writer);
#endregion
#region "Methods"
/// <summary>
/// Set properties of control
/// </summary>
private void CreateAndAddControls()
txtDate.ID = "_txtDate";
txtDate.CssClass = "dpDate";
ddlDay.ID = "_ddlDay";
ddlMonth.ID = "_ddlMonth";
ddlYear.ID = "_ddlYear";
imgCal.ID = "_imgCal";
imgCal.CssClass = "trigger";
imgCal.ImageUrl = this.ButtonImage;
//imgCal.Visible = false;
hdnDate.ID = "_hdnDate";
lblMsg.ID = "_lblMsg";
lblMsg.CssClass = "MsgLabel";
if (DisplayControl == DisplayControls.Dropdown)
txtDate.Visible = false;
this.Controls.Add(ddlDay);
this.Controls.Add(ddlMonth);
this.Controls.Add(ddlYear);
this.Controls.Add(hdnDate);
else
txtDate.Visible = true;
this.Controls.Add(txtDate);
this.Controls.Add(imgCal);
this.Controls.Add(lblMsg);
/// <summary>
/// Add Controls to the control
/// </summary>
private void RenderControls(HtmlTextWriter writer)
//if (ChildControlsCreated)
// return;
AddAttributesToRender(writer);
writer.AddAttribute(HtmlTextWriterAttribute.Class, "datePickerTable", false);
writer.RenderBeginTag(HtmlTextWriterTag.Table);//start of table
writer.RenderBeginTag(HtmlTextWriterTag.Tr);//start of tr1
if (DisplayControl == DisplayControls.Dropdown)
writer.RenderBeginTag(HtmlTextWriterTag.Td);
ddlDay.RenderControl(writer);
writer.RenderEndTag();
writer.RenderBeginTag(HtmlTextWriterTag.Td);
ddlMonth.RenderControl(writer);
writer.RenderEndTag();
writer.RenderBeginTag(HtmlTextWriterTag.Td);
ddlYear.RenderControl(writer);
writer.RenderEndTag();
writer.RenderBeginTag(HtmlTextWriterTag.Td);
hdnDate.RenderControl(writer);
writer.RenderEndTag();
else
writer.RenderBeginTag(HtmlTextWriterTag.Td);
txtDate.RenderControl(writer);
writer.RenderEndTag();
writer.RenderBeginTag(HtmlTextWriterTag.Td);
//Control ltrl1 = new LiteralControl();
//writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "None");
//writer.RenderBeginTag(HtmlTextWriterTag.Div);
////ltrl1.RenderControl(writer);
//imgCal.RenderControl(writer);
//writer.RenderEndTag();//end of div
writer.Write("<div style=\"display:none\">");
imgCal.RenderControl(writer);
writer.Write("</div>");
writer.RenderEndTag();
writer.RenderEndTag();//end of tr1
writer.RenderBeginTag(HtmlTextWriterTag.Tr);//start of tr
writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "4", false);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
lblMsg.RenderControl(writer);
writer.RenderEndTag();
writer.RenderEndTag();// end of tr2
writer.RenderEndTag();// end of table
//string newTable = "<table class='datePickerTable'";
//string endTable = "</table>";
//string newTr = "<tr>";
//string endTr = "</tr>";
//string newTd = "<td>";
//string endTd = "</td>";
////Controls.Clear();
//InitControls();
//Controls.Add(new LiteralControl(newTable + newTr + newTd));
//if (DisplayControl == DisplayControls.Dropdown)
// Controls.Add(ddlDay);
// Controls.Add(new LiteralControl(endTd + newTd));
// Controls.Add(ddlMonth);
// Controls.Add(new LiteralControl(endTd + newTd));
// Controls.Add(ddlYear);
// Controls.Add(new LiteralControl(endTd + newTd));
//Controls.Add(txtDate);
//Controls.Add(hdnDate);
//Controls.Add(new LiteralControl(endTd + newTd));
//Controls.Add(new LiteralControl("<div style=\"display:none\">"));
//Controls.Add(imgCal);
//Controls.Add(new LiteralControl("</div>"));
//Controls.Add(new LiteralControl(endTd + endTr));
//Controls.Add(new LiteralControl(newTr + "<td colspan=4>"));
//Controls.Add(lblMsg);
//Controls.Add(new LiteralControl(endTd + endTr + endTable));
/// <summary>
/// Code that embeds related resources (.js and css)
/// </summary>
/// <param name="scriptProxy"></param>
protected void RegisterResources()
// Load the calandar script
string script = this.CalendarJs;
// Load jQuery Calendar Scripts
if (script == "WebResource")
Page.ClientScript.RegisterClientScriptResource(this.GetType(), "jQueryDatePicker.Resources.ui.datepicker.js");
else if (!string.IsNullOrEmpty(script))
Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "__jqueryCalendar", this.ResolveUrl(script));
// Load the related CSS reference into the page
script = this.CalendarCss;
if (script == "WebResource")
script = Page.ClientScript.GetWebResourceUrl(this.GetType(), "jQueryDatePicker.Resources.ui.datepicker.css");
else if (!string.IsNullOrEmpty(script))
script = this.ResolveUrl(this.CalendarCss);
// Register Calendar CSS 'manually'
string css = @"<link href=""" + script + @""" type=""text/css"" rel=""stylesheet"" />";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "_calcss", css, false);
/// <summary>
/// Converts a date to a JavaScript date string in UTC format
/// </summary>
/// <param name="date"></param>
/// <returns></returns>
private static string EncodeJsDate(DateTime date)
return "new Date(\"" + date.ToString("U") + " UTC" + "\")";
/// <summary>
/// Generate Javascript for Datepicker plugin
/// </summary>
/// <returns></returns>
private string GenerateScript()
// To capture and map the various option parameters
StringBuilder sbOptions = new StringBuilder(512);
sbOptions.Append("{");
//jQuey Script
StringBuilder sbStartupScript = new StringBuilder(400);
sbStartupScript.AppendLine("jQuery(document).ready( function() {");
string dateFormat = this.DateTimeFormat;
if (!string.IsNullOrEmpty(dateFormat))
dateFormat = this.DateTimeFormat.Replace("MMM", "M").Replace("MM", "mm");
sbOptions.Append("dateFormat: '" + dateFormat + "'");
//string onSelect = this.OnClientSelect;
if (this.DisplayMode == DisplayModes.Button)
sbOptions.Append(",showOnFocus: false, showTrigger: '<button type=\"button\" class=\"trigger\">...</button>'");
else if (this.DisplayMode == DisplayModes.ImageButton)
string img = this.ButtonImage;
if (img == "WebResource")
img = Page.ClientScript.GetWebResourceUrl(this.GetType(), "jQueryDatePicker.Resources.calendar.png");
else
img = this.ResolveUrl(this.ButtonImage);
sbOptions.Append(",showOnFocus: false, showTrigger: '#" + imgCal.ClientID + "'");
sbOptions.Append(", onSelect: DateSelectedFromCalendar ");
if (this.MinDate.HasValue)
sbOptions.Append(",minDate: new Date(" + MinDate.Value.Year.ToString() + "," + (MinDate.Value.Month - 1).ToString() + "," + MinDate.Value.Day.ToString() + ")");
if (this.MaxDate.HasValue)
sbOptions.Append(",maxDate: new Date(" + MaxDate.Value.Year.ToString() + "," + (MaxDate.Value.Month - 1).ToString() + "," + MaxDate.Value.Day.ToString() + ")");
sbOptions.Append(",yearRange:' " + this.MinYear.ToString() + ":" + this.MaxYear.ToString() + "'");
//end of options
sbOptions.Append("}");
// Write out initilization code for calendar
if (this.DisplayMode != DisplayModes.Inline)
sbStartupScript.AppendLine("var cal = jQuery('#" + this.DateControlClientId + "').datepick(" + sbOptions.ToString() + ");");
else
sbStartupScript.AppendLine("var cal = jQuery('#" + this.ClientID + "Div').datepick(" + sbOptions.ToString() + ");");
sbStartupScript.AppendLine("var dp = jQuery.datepicker;");
if (this.SelectedValue.HasValue && this.SelectedValue.Value > new DateTime(1900, 1, 1, 0, 0, 0, DateTimeKind.Utc))
sbStartupScript.AppendLine("dp.setDateFor(cal[0],new Date('" + txtDate.Text + "'));");
sbStartupScript.AppendLine("dp.reconfigureFor(cal[0]);");
//******************* When dropdown changes then reflect it in calendar
if (DisplayControl == DisplayControls.Dropdown)
sbStartupScript.AppendLine("\r\n\r");
sbStartupScript.Append("$('#" + ddlDay.ClientID);
sbStartupScript.Append(",#" + ddlMonth.ClientID);
sbStartupScript.Append(",#" + ddlYear.ClientID + "').change(function() {");
// disable months and days when they are less then day months of minimum date
sbStartupScript.Append("$ddlDay=$('#" + ddlDay.ClientID + "');");
sbStartupScript.Append("$ddlMonth=$('#" + ddlMonth.ClientID + "');");
sbStartupScript.Append("$ddlYear=$('#" + ddlYear.ClientID + "');");
sbStartupScript.AppendLine("var minYear=" + this.MinYear.ToString() + ";");
///disable months of minimum year which are less then minumum date month
sbStartupScript.AppendLine("if($ddlYear.val()<=minYear && $('#" + this.DateControlClientId + "').val!=''){ alert('true');");
sbStartupScript.AppendLine("var minMonth=" + this.minMonth.ToString() + ";");
sbStartupScript.AppendLine("if($ddlMonth.val()<=minMonth){");//start of if of minMonth
sbStartupScript.AppendLine("$ddlMonth.val(minMonth);");
sbStartupScript.AppendLine("var minDay=" + this.minDay.ToString() + ";");
sbStartupScript.AppendLine("$ddlMonth.find('option:lt('+minMonth+')').hide();");
sbStartupScript.AppendLine("if($ddlDay.val()<=minDay)");
sbStartupScript.AppendLine("$ddlDay.val(minDay);");
sbStartupScript.AppendLine("}");// end of if of minMonth
sbStartupScript.AppendLine("else {");
sbStartupScript.AppendLine("$ddlDay.find('option').show();");
sbStartupScript.AppendLine("}");// end of else part of min month
sbStartupScript.AppendLine("$ddlDay.find('option:lt('+minDay+')').hide();");
sbStartupScript.AppendLine("}");// end of if part of min Year
sbStartupScript.AppendLine("else {");
sbStartupScript.AppendLine("$ddlMonth.find('option').show();");
sbStartupScript.AppendLine("}");// end of else part of min Year
///set date in calendar
sbStartupScript.AppendLine();
sbStartupScript.Append("$('#" + this.DateControlClientId + "').datepick('setDate', new Date(\n\r\r ");
sbStartupScript.Append("$('#" + ddlYear.ClientID + "').val(),");
sbStartupScript.Append("$('#" + ddlMonth.ClientID + "').val()-1,");
sbStartupScript.Append("$('#" + ddlDay.ClientID + "').val()));");
sbStartupScript.AppendLine("} );");
//******************* When calendar changes then reflect it in dropdown
sbStartupScript.AppendLine("\r\n\r");
sbStartupScript.AppendLine("function DateSelectedFromCalendar(dates) {");
if (DisplayControl == DisplayControls.Dropdown)
sbStartupScript.AppendLine("$('#" + ddlDay.ClientID + "').val(dates.length ? dates[0].getDate() : '');");
sbStartupScript.AppendLine("$('#" + ddlMonth.ClientID + "').val(dates.length ? dates[0].getMonth() +1 : '');");
sbStartupScript.AppendLine("$('#" + ddlYear.ClientID + "').val(dates.length ? dates[0].getFullYear() : '');");
if (!string.IsNullOrEmpty(this.OnClientSelect))
sbStartupScript.AppendLine(this.OnClientSelect + "();");
sbStartupScript.AppendLine("}");
//******************* Validation Script
sbStartupScript.AppendLine("\r\n\r");
sbStartupScript.AppendLine("$('form').validate({");
sbStartupScript.AppendLine("errorPlacement: $.datepick.errorPlacement,");
sbStartupScript.AppendLine("rules: {");
sbStartupScript.AppendLine(this.DateControlClientId + ": {");//start of format picker
sbStartupScript.AppendLine("required: true, dpDate: true}");//end of formate picker
sbStartupScript.AppendLine("}, ");// end of rules
sbStartupScript.AppendLine("messages: {");
sbStartupScript.AppendLine(this.DateControlClientId + ": 'Please enter a valid date (" + this.DateTimeFormat + ")'");
sbStartupScript.AppendLine("}");// end of messages
sbStartupScript.AppendLine("});"); //end of validate function
//******************* close document ready function
sbStartupScript.AppendLine("} );");
return sbStartupScript.ToString();
/// <summary>
/// Fill day month and year dropdown
/// </summary>
private void FillDropdowns()
//Fill Day Dropdown
ListItem liDay = new ListItem("Day", "0");
ddlDay.Items.Add(liDay);
for (int i = 1; i <= 31; i++)
ListItem li = new ListItem(i.ToString(), i.ToString());
ddlDay.Items.Add(li);
//Fill Month Dropdown
ListItem liMonth = new ListItem("Month", "0");
ddlMonth.Items.Add(liMonth);
string monthName = string.Empty;
for (int i = 1; i <= 12; i++)
switch (DisplayMonthType)
case DisplayMonthTypes.Full:
monthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i);
break;
case DisplayMonthTypes.Short:
monthName = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(i);
break;
ListItem li = new ListItem(monthName, i.ToString());
ddlMonth.Items.Add(li);
//Fill Year Dropdown
ListItem liYear = new ListItem("Year", "0");
ddlYear.Items.Add(liYear);
string yearDisplay = string.Empty;
for (int i = MinYear; i <= MaxYear; i++)
switch (DisplayYearType)
case DisplayYearTypes.Full:
yearDisplay = i.ToString();
break;
case DisplayYearTypes.Short:
yearDisplay = i.ToString().Substring(2);
break;
ListItem li = new ListItem(yearDisplay, i.ToString());
ddlYear.Items.Add(li);
setDropDownValue(this.SelectedValue);
private void generateDisplayMessage()
if (this.DisplayMessageLable)
if (this.DisplayControl == DisplayControls.TextBox)
lblMsg.Text = this.DateTimeFormat;
if (this.MinDate != null && this.MinDate.Value != new DateTime())
lblMsg.Text += " From " + this.MinDate.Value.ToString(this.DateTimeFormat);
if (this.MaxDate != null && this.MaxDate.Value != new DateTime())
lblMsg.Text += " To " + this.MaxDate.Value.ToString(this.DateTimeFormat);
private void setDropDownValue(DateTime? dt)
if (ddlDay.Items.Count != 0 && ddlMonth.Items.Count != 0 && ddlYear.Items.Count != 0)
if (dt != null && dt != new DateTime())
ddlDay.SelectedValue = ddlDay.Items.FindByValue(dt.Value.Day.ToString()).Value;
ddlMonth.SelectedValue = ddlMonth.Items.FindByValue(dt.Value.Month.ToString()).Value;
ddlYear.SelectedValue = ddlYear.Items.FindByValue(dt.Value.Year.ToString()).Value;
else
ddlDay.SelectedValue = "0";
ddlMonth.SelectedValue = "0";
ddlYear.SelectedValue = "0";
#endregion
}Usage Of Code in .ascx<cc2:DateTimePicker ID="dtpDOB" DisplayType="Date" DisplayMode="ImageButton" ButtonImage="../Images/calendar.png" runat="server"Changing Value from .cs file dtpDOB.SelectedValue = DateTime.Parse("01/01/2001");It is not reflected in screenHello,
According to your code, it's an ASP.NET user control problem. Please post in
ASP.NET forums where more web developers will give you help.
Thanks for your understanding.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Convert Epoch Date Time to Date Time format
I am trying to convert Epoch Date time in GMT to Human Readable Date time format in UTC. I used the one below but it returns just the date in GMT but how can get datetime in UTC ?
select To_Char( To_Date( '01.01.1970 06:00:00','DD.MM.YYYY HH24:Mi:Ss') + STARTIME / 86400,'DD.MM.YYYY HH24:Mi:ss') FROM HQ_AVAIL_DATA_RLE;
I refered a couple of forums and applied everything, but still I wouldn't get the timestamp.
Please note that i'm looking for datetime stamp, not just the date.
Thanks in advance!
Edited by: 830754 on Jan 27, 2011 11:18 AM
Edited by: 830754 on Jan 27, 2011 11:19 AMWorks for me. I see date and time (submitted 1000 for STARTTIME):
select To_Char( To_Date( '01.01.1970 06:00:00','DD.MM.YYYY HH24:Mi:Ss') + 1000 / 86400,'DD.MM.YYYY HH24:Mi:ss')
from dual
TO_CHAR(TO_DATE('01
01.01.1970 06:16:40Or do you mean something else? -
Converting UNIX time stamp to local time using T- SQL
Hi All,
I am getting DateTime in UTC time (UTC time (Coordinated Universal Time or Greenwich Mean Time)) using (datediff(ss, '1/1/1970', current_timestamp)) . I want to Convert this in my Local DateTime (CST DateTime). How to achieve this in simple way in T-SQL.
thanks,
VenkatImports System.Data.SqlTypes
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports Microsoft.SqlServer.Server
Partial Public Class UserDefinedFunctions
'Microsoft.SqlServer.Server.SqlFunction(IsDeterministic=false)
<SqlFunction()> _
Public Shared Function displayLocalTime(dt As SqlDateTime) As SqlDateTime
If (dt.IsNull) Then
Return dt
End If
Return TimeZone.CurrentTimeZone.ToLocalTime(dt.Value)
End Function
End Class
Apply it to SQL Server and use in SELECT statement
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Unable to register custom workflow activity on MS CRM 2015 Online
Hi All,
I am trying to register custom workflow activity using plugin registration tool on MS CRM 2015 Online.
Error says that 'No Plugin have been selected from list. Please select atleast one and try again'
In short my assembly is not considered as custom workflow activity.
I am giving my code let me know, If any thing is wrong.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;
namespace Training.SamplePlugin
public class SampleCustomworkflow : CodeActivity
[Input("Birthday")]
public InArgument<DateTime> BirthDate { get; set; }
[Output("NextBirthday")]
public OutArgument<DateTime> NextBirthDay { get; set; }
protected override void Execute(CodeActivityContext executionContext)
//Create the tracing service
ITracingService tracingService = executionContext.GetExtension<ITracingService>();
//Create the context
IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
if (context.PrimaryEntityName.ToLowerInvariant() == "contact")
DateTime birthDate = BirthDate.Get<DateTime>(executionContext);
DateTime nextBirthDate = new DateTime(DateTime.Now.AddYears(1).Year, birthDate.Month, birthDate.Day);
//NextBirthDay.Set(executionContext, nextBirthDate);
Entity newContact = new Entity();
newContact.LogicalName = "contact";
newContact.Id = context.PrimaryEntityId;
newContact["new_nextbirthday"] = nextBirthDate;
service.Update(newContact);
If code is correct then has somebody faced this kind of issue earlier, what is resolution.
Thanks
ApurvHave your signed your assembly ??
Microsoft Dynamics CRM Training|Our Blog |
Follow US |
Our Facebook Page |
Microsoft Dynamics CRM 2011 Application Design
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question. -
Login duration (total login) is incorrect in Agent Not Ready Detail
Hi All,
We have deployed the PCCE 10, and CUIC 10, and downloaded Cisco reporting template CCE_AF_Historical template.
When we checked the report login duration show as some 0-2037:0-31:0-48 (not readable value is coming all agents).
Since we are using cisco default template we didnt change anything on the sql query. i here with attached the sql query
what i have understood from this issue is , it is not valditating the Event valuein the following area
AgentLogOutDetails(ALODSkillTargetID, ALODLoginDateTime, TotalLoginTime, ALODEvent) AS
(Select aed.SkillTargetID,
aed.LoginDateTime,
TotalLoginTime = DATEDIFF(ss,LoginDateTime, DateTime),
aed.Event
From AgentNotReadyDetails aed
WHERE Event = 2),
SELECT SkillTargetID = ANRDU.SkillTargetID,
LoginDateTime = ANRDU.LoginDateTime,
TotalLoginTime = CASE WHEN ALOD.ALODEvent = 2 THEN ALOD.TotalLoginTime ELSE DATEDIFF(ss,LoginDateTime, (CASE WHEN DATEDIFF(ss, :end_date, (Select NowTime From Controller_Time)) > 0 THEN :end_date ELSE (Select NowTime From Controller_Time) END)) END,
TotalNotReadyTime = AgentNotReadyTotal.NotReadyTime,
ReasonCode = ANRDU.ReasonCode,
textReasonCode = ISNULL(Reason_Code.ReasonText, ' ')+'['+convert(varchar, ANRDU.ReasonCode)+']',
ReasonCodeDuration = ANRDU.ReasonCodeDuration,
FullName = Person.LastName+', '+Person.FirstName,
perNotReady = CASE WHEN ISNULL(AgentNotReadyTotal.NotReadyTime,0) = 0 THEN 0*1.0 ELSE ISNULL(ANRDU.ReasonCodeDuration,0)*1.0/ISNULL(AgentNotReadyTotal.NotReadyTime,0) END,
perLogon = ANRDU.ReasonCodeDuration*1.0/(CASE WHEN ALOD.ALODEvent = 2 THEN ALOD.TotalLoginTime ELSE DATEDIFF(ss,LoginDateTime, (Select NowTime From Controller_Time)) END),
StartDate = CONVERT(DATETIME, :start_date),
EndDate = CONVERT(DATETIME, :end_date)
FROM AgentNRDuration ANRDU
LEFT JOIN Reason_Code ON ANRDU.ReasonCode=Reason_Code.ReasonCode
LEFT JOIN AgentLogOutDetails ALOD ON (ANRDU.SkillTargetID = ALOD.ALODSkillTargetID
AND ANRDU.LoginDateTime = ALOD.ALODLoginDateTime)
LEFT JOIN AgentNotReadyTotal ON ANRDU.SkillTargetID = AgentNotReadyTotal.SkillTargetID,
Person (nolock),
Agent (nolock),
Media_Routing_Domain
WHERE Agent.PersonID = Person.PersonID
AND Agent.SkillTargetID = ANRDU.SkillTargetID
AND Media_Routing_Domain.MRDomainID = ANRDU.MRDomainID
ORDER BY FullName,
Media_Routing_Domain.EnterpriseName,
LoginDateTime,
textReasonCode
Does any come across this issue please guide us how to resolve it, since it is affecting the customer performance badly.
with Regards,
ManivannanIt sounds like the query is giving you a negative time value of about -85 days. I see a few ways this could happen:
The Agent logout events in AED (Event=2) are somehow getting DateTime values that are earlier than the login times
NowTime in table Controller_Time is earlier than the agent login times. (this seems more likely)
So, I suggest looking at the Agent_Event_Detail table on the AW/HDS to ensure that the DateTime values on Event=2 lines are later than the login times... and also check the NowTime in table Controller_Time to ensure it is correct.
Here's the NowTime query:
SELECT [NowTime]
,[TimeZone]
,[TimeZoneName]
FROM [Controller_Time]
And here's the appropriate query for AED (should return 0 results if DateTime/LoginDateTimes are correct):
SELECT [DateTime]
,[SkillTargetID]
,[MRDomainID]
,[TimeZone]
,[LoginDateTime]
,[Event]
,[RecoveryKey]
,[Duration]
,[ReasonCode]
,[DbDateTime]
FROM [Agent_Event_Detail]
WHERE Event=2 AND DateTime<LoginDateTime
-Jameson -
Refresh IE page if computer idle for a specified time with powershell
Hi,
I have a Windows 8 pc that i have created a kiosk mode for and i want to be able to check the idle time so that if the idle is more than three minutes it will close all tabs without a warning and navigate the primary tab to a specific web site.
The script needs to be constantly running i the background, I'll add the script to a scheduled task to start when the user logs in.
Could you please help me?
Cheers,
CredFXThe Windows 8 computer is a touch screen as well so idle means any mouse movement, keyboard stroke or touch of the screen.
I have found this from a site that gets the idle time, I'm just not sure how to create the IE navigation part from it.
Add-Type @'
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace PInvoke.Win32 {
public static class UserInput {
[DllImport("user32.dll", SetLastError=false)]
private static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);
[StructLayout(LayoutKind.Sequential)]
private struct LASTINPUTINFO {
public uint cbSize;
public int dwTime;
public static DateTime LastInput {
get {
DateTime bootTime = DateTime.UtcNow.AddMilliseconds(-Environment.TickCount);
DateTime lastInput = bootTime.AddMilliseconds(LastInputTicks);
return lastInput;
public static TimeSpan IdleTime {
get {
return DateTime.UtcNow.Subtract(LastInput);
public static int LastInputTicks {
get {
LASTINPUTINFO lii = new LASTINPUTINFO();
lii.cbSize = (uint)Marshal.SizeOf(typeof(LASTINPUTINFO));
GetLastInputInfo(ref lii);
return lii.dwTime;
Function getidletime
$Last = [PInvoke.Win32.UserInput]::LastInput
$Idle = [PInvoke.Win32.UserInput]::IdleTime
Write-Host ("Idle for " + $Idle.Days + " days, " + $Idle.Hours + " hours, " + $Idle.Minutes + " minutes, " + $Idle.Seconds + " seconds.")
Maybe you are looking for
-
Is it possible to create relational view on Analytic Workspace in Oracle 9i Release1
Hi All, We are in the initial stages of Oracle 9i OLAP prototype. Since the current version of BIBeans 2.5 does not work with Release 2 of Oracle 9i OLAP, we are planning to use Oracle 9i OLAP Release 1. So can you please answer the following questio
-
Suddenly the text on my screen is blurry.
My computer was fine earlier today. I went out (left it on and it went into sleep mode). When I returned, the text on the screen was all blurry. Not only that, but it changed the size of the screen so that nothing that's on it fits as it is supposed
-
Flash 8 Trial instlation problem
Hello guys, I have a big issue trying to install flash 8 downloaded from Macromedia web site. I've done it several times so I don't have corrupted download. Well, error message I've got tell me that "Administrator has configured software restrictiona
-
Upgrade single family pack?
I'm leaving Monday on a business trip for which I'll need a spreadsheet on my laptop, so today (Saturday) went to the local Apple Store and bought a copy of iWork '08. I'm working my way through Numbers right now and so far everything is going well.
-
i am currently tackling the issue of my itunes not having AAC encoder under its importing preferences when i remembered it was the reason i had to import all my CDs under the apple lossless format. (this takes up so much room although the songs are g